java - Is ArrayList.size() method cached? -


I was thinking, this is the size () method that you call current size () in local en?

I hope that it has actually been cached, when you do not add / remove items between calls from size

Am I

Updates
I am not talking about inlineing or such things. I just want to know that the method size () caches the value internally itself, or it dynamically counts every time.

I do not think I can say that it is "cached" - but this is just a field Is stored in, so it is fast enough to call it often.

The implementation of the size () of Sun JDK only:

  public full size () {return size; }  

Comments