I have a 2d array of String and I want to randomly pick element in this array. Then create new 2d array where the elements will be stored without the random pick and display the new 2d array. Here's my code :
String [][] names = { {"ria" , "maria", "steph"},
{"ann","faye", "liza"},
{"kurt","xia","laine"},
{"tiffany","fate","alysa"}};
Random pick = new Random();
int random1 = pick.nextInt(names.length);
int random2 = pick.nextInt(names[random1].length);
System.out.println("Random Pick Card: " + names[random1][random2]);
But I don't know how to create a new 2d array without the pick card. What should do next?
Aucun commentaire:
Enregistrer un commentaire