I have used RealmList for Date object and I have faced a problem with size value. In my case in debbuger I can see only 4 items but size() method shows 5. Because of that loop isn't working correctly.
Please look on attached screenshot.

Realm version(s): 4.0.0-RC1
Realm sync feature enabled: no
Android Studio version: 2.3.3
Which Android version and device: 6.0
Any chance that the date at index 4 is null?
Or does it throw IndexOutOfBoundsException?
Can you please verify getStartDates().get(4) in debugger?
It is null.
But if there is a null item at index[4], size() == 5 is correct? We have unit tests showing this behaviour: https://github.com/realm/realm-java/blob/master/realm/realm-library/src/androidTest/java/io/realm/ManagedRealmListForValueTests.java#L474
@kumien are you sure you never manually inserted null as a parameter in that list?
@cmelchior I didn't realize you can store nulls in primitive lists, is it possible to make a primitive list store only non-null values with @Required?
@Zhuinden Yes, by using @Required, the primitive list will only store non-null values.
Whole object was parsed from json and there wasn't null value. Even if I will add null value to list then it should be visible in the list. Otherwise size() method has to inform how much items we have in the list.
Not sure what you mean by it being "visible in the list"? The Android debugger apparently doesn't show null values in lists (I don't know if that is a setting somewhere), but that isn't Java's problem. If you call list.get(4) you correctly get null back, making the size 5.
But if there is a bug in how we import list data we want to get that fixed as soon as possible. Do you have the data and import code that shows this happening?
Android debugger doesn't show null as last element of list automatically, I ran into this before while debugging FragmentManager-related things where instead of just removing the fragment, they set its index to null.

null values are hidden by default. Really strange default setting if you ask me 馃槥
@kumien I assume the above answered your question, if not feel free to reopen.
Most helpful comment
nullvalues are hidden by default. Really strange default setting if you ask me 馃槥