+ 2

Collections

What is difference between Collections and ArrayList https://sololearn.com/compiler-playground/c6919t3G0CC8/?ref=app

28th May 2025, 5:43 PM
Safiullah Mohammadi
Safiullah Mohammadi - avatar
2 Antworten
+ 2
but you are asking about Collections (with s). it is not a base class, it is a helper or utility class for working with a Collection like ArrayList. It contains only static methods, which is a different, complementary approach to use, Collections are therefore different from ArrayList, but it can work with ArrayList as a parameter and then have essentially the same target data. Or it can add specific functionality to a List,
10th Jun 2025, 2:31 AM
zemiak
+ 2
In more detail, Collection is an interface - a description of properties that the ArrayList class and its superclasses must implement. This is also why some methods have the same names in both like .add() https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/Collection.html https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/ArrayList.html
29th May 2025, 11:31 PM
zemiak