You can create a character array which includes all the letters and numbers, then you can randomly select from this char array and create your own string password.
char[] chars = new char[62]; // sum of letters and numbers
int i = 0;
for(char c = 'a'; c <= 'z';c++) { // for letters
chars[i++] = c;
}
for(char c = '0'; c <= '9';c++) { // for numbers
chars[i++] = c;
}
for(char c = 'A'; c <= 'Z';c++) { // for capital letters
chars[i++] = c;
}
int numberOfCodes = 0;
String code = "";
while (numberOfCodes < 1) {//enter how much you want to generate at one time
int numChars = 8; //Enter how many digits you want in your password
for(i = 0; i < numChars; i++) {
char c = chars[(int)(Math.random() * chars.length)];
code = code + c;
}
System.out.println("Code is :" + code);
}