[Solved] JAVA – How do I generate a random number that is weighted towards certain numbers? [duplicate]
[ad_1] public static void main(String[] args){ ArrayList<Integer> list = new ArrayList<Integer>(); list.add(5);list.add(2);// to be continued … int randomInt = list.get((int) (Math.random() * list.size())); System.out.println(randomInt); } You’ll get your List of values, and then you just need to pick randomly an index and get back the value Math.random() will pick a value in [0;1[, if you … Read more