Java create subList and remove values from previous List -


i want create sublist in java , remove values in sublist previous list. program correctly creates sublist, doesn't remove correct values previouslist.

my code:

for(int i=0; i<4; i++){      list<object> sub=new arraylist<object>(prevoiuslist.sublist(0,6));       (int j=0; j<6; j++){          previouslist.remove(j);      } }     

at first j=0 , remove first element. when doing shift other elements, second element becomes first , on.

on next iteration j=1, remove second element, third...

in order fix issue, use 0 index, or iterator.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -