问题
I have an ArrayList in my Android app, and it has 2 items in it. However, its size method returns 3. I know it sounds really simply and stupid, but here is how it goes:

Why would this happen? How can an ArrayList's size return an incorrect number? This causes a null pointer exception when I'm iterating the list.
回答1:
IntelliJ has a setting about hiding null
values. Right click the variables section in the debugger and choose Customize Data Views...
. There is an option there for Hide null array elements
that you should make sure is unticked.
来源:https://stackoverflow.com/questions/30262906/arraylistsize-is-more-than-actual-number-of-objects