Java examples for java.util:Random Int
generate Random integer within a range
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int lRange = 2; int rRange = 2; System.out.println(genRandomNum(lRange, rRange)); }/*w ww .ja va 2 s . co m*/ public static int genRandomNum(int lRange, int rRange) { return lRange + (int) (Math.random() * (rRange - lRange)); } }