lele lele - 19 days ago 11
Java Question

i need to generate a random word chosen from 6 hidden words using an array in jframe

String[] FindWord = {"hello", "photo", "table", "page", "flower","salad"};
List<String> names = Arrays.asList(FindWord);
int indexOf= new Random().nextInt(names.size());
String name= names.get(indexOf);

Answer

You might want to seed your Random so you don't always get the same results

String[] FindWord = {"hello", "photo", "table", "page", "flower","salad"}; 
List<String> names = Arrays.asList(FindWord); 
int indexOf= new Random(System.currentTimeMillis()).nextInt(names.size());  
String name= names.get(indexOf);