Java examples for java.util:Random Int
get Random integer within range
//package com.java2s; import java.util.Random; public class Main { public static void main(String[] argv) throws Exception { int range = 2; System.out.println(getRandom(range)); }//from w w w .j a va 2 s. c o m final static Random ran = new Random(); public static int getRandom(int range) { return ran.nextInt(range); } }