Partitioning a list to a list of smaller lists I created a utility method ListUtils.partition(iterable, size) to partition a potentially large list to a list of smaller lists:

public class ListUtils {
    public static &lt;T&gt; List&lt;List&lt;T&gt;&gt; partition(Iterable&lt;T&gt; iterable, int size) {
        if (iterable == null) {
            return Collections.emptyList();
        }
        if (size &lt; 1) {
            List&lt;T&gt; list = new ArrayList&lt;&gt;();
            for (T item : iterable) {
                list.add(item);
            }
            return Arrays.asList(list);
        }
        List&lt;List&lt;T&gt;&gt; result = new ArrayList&lt;&gt;();
        List&lt;T&gt; segment = new ArrayList&lt;&gt;(size);
        int i = 0;
        for (T item : iterable) {
            segment.add(item);
            if (++i == size) {
                result.add(segment);
                segment = new ArrayList&lt;&gt;(size);
                i = 0;
            }
        }
        if (i &gt; 0) {
            result.add(segment);
        }
        return result;
    }
}


Unit tests:

public class ListUtilsTest {
    private &lt;T&gt; List&lt;List&lt;T&gt;&gt; partition(Iterable&lt;T&gt; iterable, int size) {
        return ListUtils.partition(iterable, size);
    }

    @Test
    public void testPartitionEmpty() {
        assertEquals(Arrays.&lt;List&lt;Object&gt;&gt;asList(), partition(Arrays.asList(), 3));
    }

    @Test
    public void testPartitionNull() {
        assertEquals(Arrays.&lt;List&lt;Object&gt;&gt;asList(), partition(null, 3));
    }

    @Test
    public void testPartitionZeroSize() {
        List&lt;Integer&gt; orig = Arrays.asList(1, 2, 3);
        assertEquals(Arrays.asList(orig), partition(orig, 0));
    }

    @Test
    public void testPartitionNegativeSize() {
        List&lt;Integer&gt; orig = Arrays.asList(1, 2, 3);
        assertEquals(Arrays.asList(orig), partition(orig, -3));
    }

    @Test
    public void testPartitionInts() {
        assertEquals(
                Arrays.asList(
                        Arrays.asList(1, 2),
                        Arrays.asList(3, 4),
                        Arrays.asList(5)),
                partition(Arrays.asList(1, 2, 3, 4, 5), 2));
    }

    @Test
    public void testPartitionStrings() {
        assertEquals(
                Arrays.asList(
                        Arrays.asList("1", "2"),
                        Arrays.asList("3", "4"),
                        Arrays.asList("5")),
                partition(Arrays.asList("1", "2", "3", "4", "5"), 2));
    }

    @Test
    public void testPartition_MultipleOfSize() {
        assertEquals(
                Arrays.asList(
                        Arrays.asList(1, 2),
                        Arrays.asList(3, 4)),
                partition(Arrays.asList(1, 2, 3, 4), 2));
    }

    @Test
    public void testPartition_Size1() {
        assertEquals(
                Arrays.asList(
                        Arrays.asList(1),
                        Arrays.asList(2),
                        Arrays.asList(3),
                        Arrays.asList(4)),
                partition(Arrays.asList(1, 2, 3, 4), 1));
    }

    @Test
    public void testPartition_BiggerSize() {
        List&lt;Integer&gt; orig = Arrays.asList(1, 2, 3, 4);
        assertEquals(
                Arrays.asList(orig),
                partition(orig, orig.size() + 11));
    }
}


Can you improve this? Are there interesting corner cases I might have missed in the tests?
I don't agree with your method of handling 0 or negative partition sizes.

A partition is always meant to be a sub-section of a whole. A partition with size 0 is impossible if the whole is non-empty, as there is no way to cut up a whole into sub-sections of size 0. (Note, an empty whole will of course be divisible into partitions of size 0). The same logic applies for negative values. I would think raising a RuntimeException such as an IllegalArgumentException would make more sense in that context. null objects shouldn't be partition-able either, as they are not even empty "wholes".

Now as for handling sub-section sizes larger than the size of your list, you already define that by having incomplete sub-sections if your sub-section size doesn't divide into your container size. You are missing a test for this, however.

A final remark: since Iterable isn't confined to Collection's measly 2 billion item limit for indexing, you might consider using a long for your partition size if you plan to 
use this for large data sets.