|
Answer» 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());
|