import java.util.*;
public class Password{
public static void main(String arg[]){
String[] al = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"};
ArrayList<String> AL = new ArrayList<String>(Arrays.asList(al));
int counter = 0;
ArrayList<String> password = new ArrayList<String>();
while(counter < 8){
password.add("na");
counter++;
}
for(int i = 0;i < 26;i++){
AL.add(al[i].toUpperCase());
}
boolean lower = false;
boolean upper = false;
boolean number = false;
while(lower == false && upper == false && number == false){
for(int i = 0; i < 8; i++){
int random = (int)(Math.random() * 62);
password.set(i,AL.get(random));
if(random >= 0 && random < 26)
lower = true;
if(random >= 26 && random < 36)
number = true;
if(random >= 36){
upper = true;
password.add(al[i].toUpperCase());
}
}
}
ArrayList<String> pass = new ArrayList<String>();
System.out.println(password);
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.