java - How to remove a string from an arraylist randomly -
so program supposed user inputs name text box , presses button add array displayed onto text area. thing can't figure out how take away name arraylist randomly. noob programmer.
here have far.
random r = new random(); arraylist <string> names = new arraylist<string>(); private void btnaddactionperformed(java.awt.event.actionevent evt) { names.add(txtadd.gettext()); txtdisplay.settext("" + names); }
names.remove(r.nextint(names.size()));
Comments
Post a Comment