I was wondering if there is a way (simple way hopefully) to take the elements of an array list and put it into 2 other array lists. If the original array list contained ten numbers, is there a way to split the array list in half giving 5 numbers to each new array list? Thanks for your help!
            Asked
            
        
        
            Active
            
        
            Viewed 1,988 times
        
    0
            
            
        - 
                    2You might want to look at http://stackoverflow.com/questions/5731042/split-array-into-two-parts-without-for-loop-in-java – Brian Hoover Feb 05 '15 at 23:23
 - 
                    Can you be more specific? For example, can you show us what you've tried? It's a lot easier to fix well-defined problems. – ryanyuyu Feb 05 '15 at 23:23
 - 
                    Use my code it works for odd as well even list size int listSize = listOfArtist.size(); int mid = 0; if (listSize % 2 == 0) { mid = listSize / 2; Log.e("Parting", "You entered an even number. mid " + mid + " size is " + listSize); } else { mid = (listSize + 1) / 2; Log.e("Parting", "You entered an odd number. mid " + mid + " size is " + listSize); } leftArray = new ArrayList
(listOfArtist.subList(0, mid)); rightArray = new ArrayList – Hitesh Sahu Jan 07 '16 at 05:28(listOfArtist.subList(mid, listSize));  
1 Answers
0
            
            
        You could use this method:
newArrList = arrayYouWantToSplit.subList(int fromIndex, int toIndex);
        Benjamin W.
        
- 46,058
 - 19
 - 106
 - 116
 
        Ammar S
        
- 91
 - 8
 
- 
                    
 - 
                    obviously yea, It seems that you may not understand what a sub list or index means. – Ammar S Feb 06 '15 at 14:53