How to find the length of ArrayList in Java?

To find the length of ArrayList in Java, call ArrayList.size().

Here's how you do it:

var arrayList = new ArrayList<>();
arrayList.add("one");
arrayList.add("two");

int arrayListLength = arrayList.size();

System.out.println(arrayListLength); // 2