import java.util.Random; public class randomChars { public static void main(Stri
ID: 3612409 • Letter: I
Question
import java.util.Random;
publicclass randomChars
{
publicstatic voidmain(String[] args){
Random gen =new Random();
int keyLength, maxLength = 26, minLength=5;
boolean[]used = new boolean[maxLength];
String key = "";
int i,j,usedcount=0;
int creationCount =0;
for(i=0;i<maxLength;i++){
used[i]=false;
//creationCount++;
}
keyLength =gen.nextInt(maxLength-minLength)+minLength;
while(usedcount<keyLength){
j=gen.nextInt(maxLength);
if(!used[j]){
used[j]=true;
usedcount++;
key+=(char)(j+65);
}
}
System.out.println("Key = " +key);
}
}