how can a method return a generic type in java code example
Example: Java method that returns a generic type
public static <T> T getRandomValue(List<T> listOfPossibleOutcomes, int numPossibilities) {
int r = RandomNumberGenerator.getRandIntBetween(0, numPossibilities);
return listOfPossibleOutcomes.get(r);
}
public static <T> T getRandomValueFromGenericList(List<T> list) {
Collections.shuffle(list);
return list.get(0);
}