As far as built-in functionality, you could use List#subList(int, int)
:
int size = original.size();
List<Integer> first = original.subList(0, size / 2);
List<Integer> second = original.subList(size / 2, size);
Whether or not you want to use subList()
depends on what you're doing with the contents. subList()
returns views into the original list (instead of actually copying). Make sure you read the javadoc. Here's a snippet:
Returns a view of the portion of this list between the specified
fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and
toIndex are equal, the returned list is empty.) The returned list is
backed by this list, so non-structural changes in the returned list
are reflected in this list, and vice-versa. The returned list supports
all of the optional list operations supported by this list.
Also, I can't really speak to the performance of subList()
and how it may or may not meet your requirements. I'd imagine since it's just creating views and not copying that it'd be relatively fast. But again, pretty situational, and you'd need to profile it either way to know.