Collections is a public class, then we can call its implicit default constructor. It doesn’t have private constructor, which would prevent object creation or force to have static factory method. When I do instantiate as new Collections(), i get error as “Constructor not visible”. In short why can’t we have instance of java.util.Collections class? Thanks.
Collections is a public class, then we can call its implicit default constructor. It
Share
From the documentation: “This class consists exclusively of static methods that operate on or return collections.”
In other words,
Collectionsis just a collection of methods. An instance of it would not make any sense. It is just like the math functions: You don’t have an instance of math, you just use the functions.It is not an
interfaceas it has concrete methods.