How to add character from JOptionPane to an array and prevent duplicate entries

edited April 2017 in How To...

How would I go about adding letters placed inside the pane to an array so that it saves for printing? (pseudocode)

String x; x= JOptionPane.showInputDialog(null, "letter entry"); char y= x.charAt(0);

So it takes x and turns it to a char, but how would I add the letters inputted into an array? It takes one letter at a time, so new letters would be added as each input is accepted.

Also, how would I be able to prevent duplicates in this? Say the user entered "a" and tried to enter "a" again, it would create an error dialogue and ask for a different letter. Thanks in advance :)

Answers

Sign In or Register to comment.