mardi 29 septembre 2015

How to only choose elements in an array with a specific length

public String[] words={"cat", "dog", "rodeo", "bird", "lookers", "skid");

.

// Picks a random word from the dictionary, given the length of the word
public String pickWord(int size)
{

}

So if a user inputs 4, it randomly chooses a word in the word array with 4 letters, and randomly. I have created a rand variable from the Random class for that. So how do I choose an element in the array with the same number of letters as the number the user inputted.




Aucun commentaire:

Enregistrer un commentaire