Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Removing specific element from a list

843789Nov 21 2009 — edited Nov 21 2009
Hello, 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 19 2009
Added on Nov 21 2009
1 comment
255 views