Here you can find the source of randomWithinRange(int min, int max)
public static int randomWithinRange(int min, int max)
//package com.java2s; //License from project: Open Source License public class Main { public static int randomWithinRange(int min, int max) { return (int) Math.round(Math.random() * (max - min) + min); }//from w w w.j a v a 2 s . com }