To find how many elements an ArrayList contains, call .size():
ArrayList<String> names = new ArrayList<>();
names.add("Alice");
names.add("Bob");
System.out.println(names.size()); // 2
This is the equivalent of .length for arrays, but notice the difference: arrays use a field (arr.length with no parentheses), while ArrayList uses a method (.size() with parentheses). Mixing them up causes a compiler error.
You can also check if a list is empty with .isEmpty(), which returns true when .size() is . Using .isEmpty() is clearer than writing list.size() == 0 because it communicates your intent directly.