To generate random characters in Java, do this:
(char)('a' + new java.util.Random().nextInt(26))
.Here's how you do it:
char randomCharacter = (char)('a' + new java.util.Random().nextInt(26));
System.out.println(randomCharacter); // a … z
Both lowercase and uppercase
The first snippet will generate only lowercase characters. Here's how you can generate both lowercase and uppercase:
char randomCharacter = (char)((new java.util.Random().nextBoolean() ? 'a' : 'A') + new java.util.Random().nextInt(26));
System.out.println(randomCharacter); // a … z, A … Z