I'm trying to create an array list of arrays. When I'm done, I want the array list to look like this:
[ [Mary] , [Martha,Maggie,Molly] ]
I'm trying to accomplish this by first defining "Mary" as a string array of length 1, and defining "Martha, Maggie, Molly" as a string array of length three. Then I attempt to add these arrays to an array list. But alas, the array list will not accept the arrays. Take a look:
String[] s1 = new String[1];
String[] s3 = new String[3];
ArrayList<String[]> list1 = new ArrayList<String[]>();
s1[0]="Mary";
s3[0]="Martha";
s3[1]="Maggie";
s3[2]="Molly";
list1.add(s1[0]);
list1.add(s3[0]);
list1.add(s3[1]);
list1.add(s3[2]);
Any ideas on how I can add these arrays to list1, in order to form an array list of arrays?