Is ArrayList.size() method cached?

Posted by Peterdk on Stack Overflow See other posts from Stack Overflow or by Peterdk
Published on 2010-05-18T11:39:50Z Indexed on 2010/05/18 11:50 UTC
Read the original article Hit count: 240

Filed under:
|
|

I was wondering, is the size() method that you can call on a existing ArrayList<T> cached? Or is it preferable in performance critical code that I just store the size() in a local int?

I would expect that it is indeed cached, when you don't add/remove items between calls to size().

Am I right?

© Stack Overflow or respective owner

Related posts about java

Related posts about arraylist