java restrict List items -
this question has answer here:
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
Post a Comment