I may get a Map of many many items that needs to be requested to an API.In order to improve performance, I thought about splitting that list into smaller sublists, and querying the API with this small subset.For that, I came to this code and was wondering what was your opinion on it.This is some banal initiator I used to test my code:Map<String, Integer> map = new LinkedHashMap<String, Integer>();for (int i = 0; i < 550;i ++) {    map.put(String.valueOf(i), i);}Now the real code:    int length = 100;    List<Integer> items = new LinkedList<Integer>(map.values());    int pages = (int) Math.ceil((double) items.size() / length);    for (int i = 0; i < pages; i++) {        List<Integer> sub = items.subList(i * length, ((i+1) * length > items.size() ? items.size() : (i+1) * length));        System.out.println(sub.get(0));        System.out.println(sub.get(sub.size() - 1));        System.out.println(--);        // In my case, I would call the API here, at that place, using the sublist    }The final output is:099--100199--200299--300399--400499--500549--This works great. What's your opinion on it?
Split a Map into sublists
java;linked list;hash table
The implementation is simple enough to require any comments. Just a few things:Is LinkedList a requirement? Can't it be done by an ArrayList?Use Math.min while making the subList.An alternative for simpler solutionYou can add the Guava library to your project and use the Lists.partition method, e.g.List<Integer> items = ...List<List<Integer>> subLists= Lists.partition(items, pageSize);