Possible Duplicate:
Random string from string array list
How can I make it where i can press a button and it display one sting (words) at random from a long list of of other strings that i have already set.
Possible Duplicate:
Random string from string array list
How can I make it where i can press a button and it display one sting (words) at random from a long list of of other strings that i have already set.
List<String> list = new ArrayList<String>();
list.add(...);
list.add(...);
list.add(...);
Random rand = new Random();
String random = list.get(rand.nextInt(list.size()));
or:
Collections.shuffle(list);
String random = list.get(0);