Hi there everyone,
As you will be able to gather from this code, I am a total beginner. I'm trying to make the basis of a complex (pseudo)random password generator, but instead of 4 chars it is printing a 3 digit number.
Any help would be greatly appreciated! Thanks
public class PasswordGen { public static void main (String[] args) { char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray(); int w = (int) ((Math.random() * 25 +1)); // pick a letter of the alphabet int x = (int) ((Math.random() * 25 +1)); int y = (int) ((Math.random() * 25 +1)); int z = (int) ((Math.random() * 25 +1)); char place1 = (alphabet[w]); // assign letter of the alphabet to place in string below char place2 = (alphabet[x]); char place3 = (alphabet[y]); char place4 = (alphabet[z]); System.out.println(place1 + place2 + place3 + place4); } }