I have a method that does a lookup of some elements and returns them to the user:
List<DailyPrayer> dailyPrayers = (List<DailyPrayer>) query.execute();
return dailyPrayers;
These are daily prayers so I want the user to see a different prayer each time so they do not get bored with seeing the same content in the sam开发者_运维知识库e order over and over.
How can I randomize the List?
Collections.shuffle(list)
Randomly permutes the specified list using a default source of randomness. All permutations occur with approximately equal likelihood.
You can use Collections.shuffle(dailyPrayers);
shuffle(List<?> list)
Randomly permutes the specified list using a default source of randomness.
精彩评论