Here you can find the source of randomEnum(Class
private static <T extends Enum<?>> T randomEnum(Class<T> c)
//package com.java2s; //License from project: Open Source License import java.util.Random;; public class Main { private static <T extends Enum<?>> T randomEnum(Class<T> c) { Random random = new Random(); int r = random.nextInt(c.getEnumConstants().length); return c.getEnumConstants()[r]; }/*w ww . jav a 2s .co m*/ }