android - convert string array in java -
i can convert array so:
string [] [] friend = new string [] [] {{{robert, marie}, {jhony, eva}, {mike, laura}, {adrian, rachel}, {kristen, anthony}};
choose 2 couples @ random , result this:
string [] [] friend = new string [] [] {{{robert, marie}, {adrian, rachel}};
to later create so:
string [] friendfin = new string [] {{robert, marie, adrian, rachel}};
anyone can help me code please ... thanks
here 1 way:
string[][] friends = new string[][]{ {robert, marie}, {jhony, eva}, {mike, laura}, {adrian, rachel}, {kristen, anthony} }; list<string> list = new arraylist<string>(); for(string[] array : friends) { for(string friend : array) list.add(friend); } collections.shuffle(list); string[] friendfin = new string[list.length]; list.toarray(friendfin); // fill array friendfin = arrays.copyof(friendfin, 4);
java android
No comments:
Post a Comment