Here you can find the source of genRandomNumber(int begin, int end)
public static int genRandomNumber(int begin, int end)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { public static int genRandomNumber(int begin, int end) { int step = Math.abs(end - begin); int random = new Random(System.nanoTime()).nextInt(step); return Math.min(begin, end) + random; }//from w ww . j a va 2 s . com }