| How to Get size of Array and ArrayList in Java Programming?
There are certain property from which we can get the size for both array and for arraylist.
(1)Array:- To get the length of an array we can use length keyword to get the size.
int[] array=new int[4]
System.out.println("Size of Array is" +array.legth);
(2)ArrayList:-To get the size of Array list we use keyword size to get the size. And below list the syntax
ArrayList alist=new ArrayList();
alist.add("crackyourinterview");
alist.add("dotnet");
alist.add("sqlserver");
System.out.Println("Size of ArrayList" +alist.size());
| | |