MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / random

Method random

onjava/Enums.java:10–13  ·  view source on GitHub ↗
(Class<T> ec)

Source from the content-addressed store, hash-verified

8public class Enums {
9 private static Random rand = new Random(47);
10 public static
11 <T extends Enum<T>> T random(Class<T> ec) {
12 return random(ec.getEnumConstants());
13 }
14 public static <T> T random(T[] values) {
15 return values[rand.nextInt(values.length)];
16 }

Callers 9

randomMailMethod · 0.95
mainMethod · 0.95
randomSelectionMethod · 0.95
mainMethod · 0.95
playMethod · 0.95
randomSelectionMethod · 0.95
randomSelectionMethod · 0.95
mainMethod · 0.45
conditionMethod · 0.45

Calls

no outgoing calls

Tested by 2

mainMethod · 0.76
conditionMethod · 0.36