+ 4
Array Shuffling( java)?
I want to shuffle array list. for example : I have two arrays String []Ab={"a","b"}; String []Bc={"c","d"}; Now I want to shuffle and merge them like "ac" or "bd"or "bc"or"ad" How is this possible?
1 ответ
+ 22
String[] Ab = {"a", "b"};
String[] Bc = {"c", "d"};
int rand1 = (int)Math.round(Math.random());
int rand2 = (int)Math.round(Math.random());
System.out.println(Ab[rand1] + Bc[rand2]);