mercredi 27 avril 2016

How to generate an array containing the number of random strings where each string will have between 3 and 8 lower-case letters, inclusive

I want to create a method where I will give parameter of size and create an array of random strings with each having at least 3 and at most 8 lower case letters, inclusive.

Edit: This is what I tried :

public static String[] makeRandomStringList(int size) {
String[] str = new String[size];
for (int i =0; i <size ; i++) {
   str[i]= randomFill();
}
    return str;
}

public static String randomFill() {
Random rd = new Random();
String randomNum = rd.nextLine();//nextLine() is undefined for random type so I don't know what else to do.
return randomNum;
}




Aucun commentaire:

Enregistrer un commentaire