Split a Map into sublists 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&lt;String, Integer&gt; map = new LinkedHashMap&lt;String, Integer&gt;();
for (int i = 0; i &lt; 550;i ++) {
    map.put(String.valueOf(i), i);
}


Now the real code:

    int length = 100;
    List&lt;Integer&gt; items = new LinkedList&lt;Integer&gt;(map.values());
    int pages = (int) Math.ceil((double) items.size() / length);

    for (int i = 0; i &lt; pages; i++) {
        List&lt;Integer&gt; sub = items.subList(i * length, ((i+1) * length &gt; 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:


0
99
--
100
199
--
200
299
--
300
399
--
400
499
--
500
549
--



This works great. What's your opinion on it?
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 solution
You can add the Guava library to your project and use the Lists.partition method, e.g.

List&lt;Integer&gt; items = ...
List&lt;List&lt;Integer&gt;&gt; subLists= Lists.partition(items, pageSize);