JAVA

Difference between Collection and Collections in Java

seoca 2019. 2. 26. 03:09



Collection - Interface

Collection is a base interface of the Java Collection Framework for List, Set and Queue.














Collections - class

Collections is a class in java.util package and it is utility class for Collection.

Collections class has methods for Sorting, Searching etc


Example

Collections.addAll(A,B); 

Collections.addAll method takes all of the elements of 'B' and fetch the elements to the collection 'A'


Collections.sort(A); 

Collections.sort method sorts the element of specified list 'A' in ascending order.



Reference

https://www.quora.com/What-are-the-main-differences-between-Collection-and-Collections-in-Java

https://www.geeksforgeeks.org/collections-sort-java-examples/