I want the function to generate random characters from A-Z without repeating if it's called again. For example, i called it in my main first and it generates an A character. If i called it the second time, it shouldn't generate A again. How to do it?
public static void random(){
Random r = new Random();
char c = (char)(r.nextInt(26) + 'A');
System.out.print(c);
}
If this helps, what i'm planning is to put it on a hashmap as a key and it shouldn't have the same characters.
Aucun commentaire:
Enregistrer un commentaire