Removing specific element from a list
843789Nov 21 2009 — edited Nov 21 2009Hello, I'm very new to java, and to programming in general.
I'm trying to write a secret santa app for my family for christmas. Essentially the idea is that 7 names are put into a list, and each time a name is "pulled" (i.e. randomly assigned to a name /= itself) it will be removed from the list of available names to assign.
String[] nList = { name2, name3, name4, name5, name6, name7 }; // store names for random use
Random r = new Random();
name1assign = nList[r.nextInt(nList.length)];
String[] nList2 = { name1, name3, name4, name5, name6, name7 };
name2assign = nList2[r.nextInt(nList2.length)];
My goal for this is to take the string that is equal to name1assign, and remove an element with that string from nList2.
Can anyone give me some advice in this matter?
Thanks.