1 Collection<Object> list = new ArrayList<>();
2 list.size();
3
4 // All collections use size()
5 // array use array. length
6
1import java.util.ArrayList;
2import java.util.List;
3public class Demo {
4 public static void main(String[] args) {
5 List aList = new ArrayList();
6 aList.add("Apple");
7 aList.add("Mango");
8 aList.add("Guava");
9 aList.add("Orange");
10 aList.add("Peach");
11 System.out.println("The size of the ArrayList is: " + aList.size());
12 }
13}