@Test public void testRandomItem() { for (int j = 0; j < 10; j++) { Map<Integer, Integer> map = new HashMap(); for (int i = 0; i < 1000000; i++) { Integer integer = RandomUtil.randomItem(new Integer[]{10, 30, 50}); if (map.containsKey(integer)) { map.put(integer, map.get(integer) + 1); } else { map.put(integer, 1); } } int count = map.get(10) + map.get(30) + map.get(50); String str = "10/30/50 =" + map.get(10) + ":" + map.get(30) + ":" + map.get(50) + "(" + count + ")"; System.out.println(str); } }
public static <T> T randomItem(T[] param) { int index = integer(0, param.length); return param[index]; }
RandomUtil { public static <T> T randomItem(T[] param) { int index = integer(0, param.length); return param[index]; } }
RandomUtil { public static <T> T randomItem(T[] param) { int index = integer(0, param.length); return param[index]; }  }
RandomUtil { public static <T> T randomItem(T[] param) { int index = integer(0, param.length); return param[index]; }  static int integer(int scopeMin, int scoeMax); static String number(int length); static String String(int length); static String MixString(int length); static String LowerString(int length); static String UpperString(int length); static String ZeroString(int length); static String toFixdLengthString(long num, int fixdlenth); static String toFixdLengthString(int num, int fixdlenth); static int getNotSimple(int[] param, int len); static T randomItem(T[] param); static String uuid(); static String UUID(); static String squid(String hostFeature); static T randomItem(T[] param, double[] percentum); }
RandomUtil { public static <T> T randomItem(T[] param) { int index = integer(0, param.length); return param[index]; }  static int integer(int scopeMin, int scoeMax); static String number(int length); static String String(int length); static String MixString(int length); static String LowerString(int length); static String UpperString(int length); static String ZeroString(int length); static String toFixdLengthString(long num, int fixdlenth); static String toFixdLengthString(int num, int fixdlenth); static int getNotSimple(int[] param, int len); static T randomItem(T[] param); static String uuid(); static String UUID(); static String squid(String hostFeature); static T randomItem(T[] param, double[] percentum); static final String ALLCHAR; static final String LETTERCHAR; static final String NUMBERCHAR; }