Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating random words in Java?

I wrote up a program that can sort words and determine any anagrams. I want to generate an array of random strings so that I can test my method's runtime.

public static String[] generateRandomWords(int numberOfWords){
String[] randomStrings = new String[numberOfWords];
Random random = Random();
    return null;
}

(method stub)

I just want lowercase words of length 1-10. I read something about generating random numbers, then casting to char or something, but I didn't totally understand. If someone can show me how to generate random words, then I should easily be able to just use a for loop to insert the words into the array. Thanks!

like image 784
Mr_CryptoPrime Avatar asked Feb 10 '11 00:02

Mr_CryptoPrime


1 Answers

Why generating random words? When you can use some dictionaries.

like image 109
Yanick Rochon Avatar answered Oct 05 '22 13:10

Yanick Rochon