next Random Int - Android java.util

Android examples for java.util:Random

Description

next Random Int

Demo Code

import java.util.Random;

public class Main {
  private static final Random GLOBAL_RANDOM = new Random();

  public static int nextRandInt(int max) {
    GLOBAL_RANDOM.setSeed(System.currentTimeMillis());
    return GLOBAL_RANDOM.nextInt(max);
  }//from w w w  .  j av  a  2  s.  co  m

  public static int nextRandInt(int min, int max) {
    return min + nextRandInt(max - min);
  }

}

Related Tutorials