1

I've got ArrayList of custom objects. There are near 200 of them. When I use debug mode I explore my list in Eclipse variables tab and see that it is split like this: array [0...99] [100...199] [200...201] That looked strange to me. Then I found out that when I use for each loop to run through ArrayList I've got only first 100 items. Could you just explain these mechanism to me?

Here is my code

 public void saveMakeList(ArrayList<ParamItem> list){

    for(ParamItem item:list){
        ContentValues values=new ContentValues();
        values.put(NATIVE_ID, item.nativeID);
        values.put(PART_URI, item.partUri);
        values.put(MAKE_NAME, item.name);
        db.insertOrThrow(MAKE_TABLE, null, values);

    }
}
2
  • 1
    Eclipse just does this to make it easier for you to browse large arrays. If you want someone to explain your for loop to you, you're going to have to post it. Commented Feb 20, 2011 at 22:02
  • So what is the question? Are you saying that list.size == 200 and you are only getting 100 out? I don't think that's possible unless you are modifying the list. Commented Feb 20, 2011 at 23:11

2 Answers 2

1

If this code fails to operate on every item in the list, it must be because something is throwing an exception before you have completed the list; the likeliest candidate is the method called "insertOrThrow". You could wrap that call in a try-catch structure to handle the exception for whichever items are failing without exiting the loop and the method prematurely.

Sign up to request clarification or add additional context in comments.

Comments

0

Actually the enhanced for loop should look like this

for (final Room room : rooms) {
          // Here your room is available
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.