java restrict List items -


i new java. have 5000 items in list. want loop through list can 100 items @ time. have following code:

   list<processqueuebatch> processqueuebatchlist =          repository.getprocessqueue("jor"); (processqueuebatch queuebatch : processqueuebatchlist)      {     // processing       } 

i want processing of first 100 items in list , next 100 items , again next 100 items until 5000 items processed. have total 5000 items in list. how can modify loop or list can 100 items @ time.

any appreciated.

you can use list.sublist(int, int) first k items processqueuebatchlist so:

int k = 100; list<processqueuebatch> newlist = new arraylist<>(processqueuebatchlist.sublist(0, k)); 

you should able take here...


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -