Here you can find the source of getRandomNumber(int max, boolean include0)
public static int getRandomNumber(int max, boolean include0)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { /**//from ww w .jav a 2 s. com * Returns a random number, up to the given maximum. */ public static int getRandomNumber(int max, boolean include0) { Random random = new Random(); int i = random.nextInt(max + 1); return (i == 0 && !include0 ? 1 : i); } }