What is Collection and Collections?
Collection: Collection in Java is data structure in which logic is already given. It is an Interface. Suppose if we create an array then we have to create logic there then use it. But in java we have collections in which we dont have to create logic, they are already built we just have to use it.
In array, we will get direct logic of dynamic array. In this we lead with heterogenous data. It consists of List, Queue, Set.
For Example:
class A{
public static void main(){
Arraylist a =new Arraylist();
a.(10);
a.(“Hello”);
a.(10.3);
System.out.println(a);
} }
Output: [10, Hello, 10.3]
Collections: Collections is a class. We can do sorting and searching methods here.
For example:
class A{
public static void main(){
Arraylist a =new Arraylist();
a.(10);
a.(5);
a.(1050);
a.(100);
Collections.sort(a);
System.out.println(a);
} }
Output: [5, 10, 100, 1050]