Split an ArrayList into Multiple Small ArrayLists in Java
We shall use
to get a view of a portion of the original list
Sample Code:
ArrayList<String> BigList=new ArrayList<String>();
BigList.add("0");
BigList.add("1");
BigList.add("2");
BigList.add("3");
BigList.add("4");
BigList.add("5");
ArrayList<String> SmallList=BigList.subList(0,3);
Which will give elements from 0th Index to 3rd Index.
Reference:
http://stackoverflow.com/questions/2895342/java-how-can-i-split-an-arraylist-in-multiple-small-arraylists
We shall use
subList(int fromIndex, int toIndex) to get a view of a portion of the original list
Sample Code:
ArrayList<String> BigList=new ArrayList<String>();
BigList.add("0");
BigList.add("1");
BigList.add("2");
BigList.add("3");
BigList.add("4");
BigList.add("5");
ArrayList<String> SmallList=BigList.subList(0,3);
Which will give elements from 0th Index to 3rd Index.
Reference:
http://stackoverflow.com/questions/2895342/java-how-can-i-split-an-arraylist-in-multiple-small-arraylists
No comments:
Post a Comment