Junior — Middle
Is Collections a class or an interface in Java?
sobes.tech AI
Answer from AI
In Java, Collections is a class, not an interface. It is located in the java.util package and contains static methods for working with collections, such as sorting, searching, creating immutable collections, etc.
Example of usage:
List<String> list = new ArrayList<>();
Collections.sort(list); // sorting the list
The interface that describes collections is called Collection (without the "s" at the end). It is the base for all collections in Java, such as List, Set, and Queue.