public static int randomInt(int a,int b,boolean excludeZero){
  double randVal=rand.nextDouble() * (b - a);
  int randNum=a + (int)Math.round(randVal);
  if (a < 0 && b > 0 && excludeZero) {
    while (randNum == 0) {
      randNum=((int)(a + rand.nextDouble() * (b - a)));
    }
  }
  return randNum;
}

public static int randomInt ( int a , int b , boolean excludeZero ) { double randVal = rand . nextDouble ( ) * ( b - a ) ; int randNum = a + ( int ) Math . round ( randVal ) ; if ( a < 0 && b > 0 && excludeZero ) { while ( randNum == 0 ) { randNum = ( ( int ) ( a + rand . nextDouble ( ) * ( b - a ) ) ) ; } } return randNum ; }
return a random number between a and b . a boolean flag is included if zero is to be excluded .
