I have 2 chars I need converting to a string. I can convert one no problem but how do I turn 2 randomly generated chars into one string? Here is my code so far, the aim of my program is to generate two chars at random and return them:
import java.util.Random;
public class PasswordGenerator {
Random rand = new Random();
public String uppercaseLetters() {
char char1;
char char2;
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String result;
char1 = alphabet.charAt(rand.nextInt(25));
char2 = alphabet.charAt(rand.nextInt(25));
result = String.valueOf(char1, char2);
return result;
}
public static void main(String[] args) {
PasswordGenerator pg = new PasswordGenerator();
System.out.println(pg.uppercaseLetters());
}
}