You are trying to access a private member of an ArrayList , parts of its internal work that should not be used externally
If you want to get the size of the arraylist, you want to use the method:
arraylist.size()
Why does it look like this
This gives the ArrayList class the ability to store the size in whatever way it wants. It just returns size , perhaps, but instead, it could do a few other things. For example, he could calculate the size lazily, in which he calculates only if someone asked him to, then he keeps this value until it becomes invalid (as more objects are added). This would be useful if calculating the size was expensive (it is very unlikely that it would take place here), it often changed and was called only occasionally.
source share