Java – How to get size of ArrayList

Size of ArrayList can be find by size() method. In size method, it will return value in integer.

Example of finding size in ArrayList in Java

ArrayList<String> arlist=new ArrayList<String>();

arlist.add("First Element");
arlist.add("Second Element");
arlist.add("Third Element");
arlist.add("forth Element");
arlist.add("fifth Element");

int sizeOfArrayList=arlist.size();

System.out.println("Size of ArrayList :"+sizeOfArrayList);

Output

Size of ArrayList :5

Tags:

Bookmark  

 

Leave a Reply

Security Code:

 

  Random Post