<a href="https://coldfusion.adobe.com/profile/neoplay">neoplay</a> Java also has the .isEmpty() method as well as .size() method. Size needs to be calculated, isEmpty() can just check for 1 key/value and then stop at that point.
It may be obvious to you, but I didn't know if:
it does use size() or isempty()
that java's size() method calculates on the fly
So the investigation was to see if calling size counts the items when called. From the timings it seems that internally the size is updated as key/values are added.