java - How to add string arrays to array list -


i'm trying create array list of arrays. when i'm done, want array list this:

[ [mary] , [martha,maggie,molly] ] 

i'm trying accomplish first defining "mary" string array of length 1, , defining "martha, maggie, molly" string array of length three. attempt add these arrays array list. alas, array list not accept arrays. take 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 can add these arrays list1, in order form array list of arrays?

you're adding individual strings arraylist instead of string arrays created.

try doing:

list1.add(s1); list1.add(s3); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -