return word;
word = firstWord + secondWord + thirdWord;
System.out.println(word);
the two bottom lines are unreachable code. Return obviously returns from the method to the main program, thus ends the execution flow of the method before your word is set, your return should be NULL. Have you tried this method even once?
(Also Eclipse should mark unreachable code)
Simpler way:
public static String createWord() {
String word = "cat";
return word;
}
r is a random object that is used for random real values between 0 and 1. The method nextInt(int n) returns a pseudorandom integer number between 0 (inclusive) and n (exclusive) on a random object.
Thus r.nextInt(21) gives a random int between 0 and 20, adding +1 shifts the range from 1 to 21.
while(true){
My laptop overheats just by seeing this.