Here you can find the source of randLocation(int min, int max)
public static int randLocation(int min, int max)
//package com.java2s; //License from project: Apache License public class Main { public static int randLocation(int min, int max) { double rand = Math.random(); int temp = (int) ((rand * (max - min)) + min); if (((int) (rand * 1000) % 2) == 0) { temp *= -1;//w ww.j a va2s .c o m } return temp; } }