Why Collectors
class is final in Java 8? I want to extend Collectors class in my own class MyCollectors
. There I will add additional methods which is not existing available in Collectors
class.
Collectors
is final because it only contains static
utility methods. It cannot be instantiated (its constructor is private
), and therefore there would be no meaning to sub-classing it.
You can create your own MyCollectors
class independent of Collectors
.
Or if you want to access Collectors
methods via your MyCollectors
, you can create wrappers of all the Collectors
static methods within your MyCollectors
class.