Example usage for java.util Random Random

List of usage examples for java.util Random Random

Introduction

In this page you can find the example usage for java.util Random Random.

Prototype

public Random() 

Source Link

Document

Creates a new random number generator.

Usage

From source file:Main.java

public static void main(String[] args) {
    new Random().ints().limit(5).forEach(System.out::println);

}

From source file:Main.java

public static void main(String[] argv) {

    Random r = new Random();
    int randint = Math.abs(r.nextInt()) % 11;
    System.out.println(randint);//from  w w w  . j  a  va2  s. c o  m
}

From source file:Main.java

public static void main(String[] args) {
    Random rand = new Random();
    for (int i = 1; i <= 100; i++) {
        int randomNum = rand.nextInt((999 - 100) + 1) + 100;
        System.out.println(randomNum);
    }/*from w  w  w.  ja  va2 s.co m*/
}

From source file:Main.java

public static void main(String args[]) {

    Random randomno = new Random();

    // check next Gaussian value  
    System.out.println("Next Gaussian value: " + randomno.nextGaussian());
}

From source file:Main.java

public static void main(String args[]) {

    Random randomno = new Random();

    // check next float value  
    System.out.println("Next float value: " + randomno.nextFloat());
}

From source file:Main.java

public static void main(String args[]) {

    Random randomno = new Random();

    // check next int value  
    System.out.println("Next int value: " + randomno.nextInt());
}

From source file:Main.java

public static void main(String args[]) {

    Random randomno = new Random();

    // check next double value  
    System.out.println("Next double value: " + randomno.nextDouble());
}

From source file:Main.java

public static void main(String args[]) {

    Random randomno = new Random();

    // check next int value  
    System.out.println("Next int value: " + randomno.nextInt(10000));
}

From source file:Main.java

public static void main(String[] args) {
    Random random = new Random();
    for (int i = 0; i < 1000000000; i++) {
        float f = random.nextFloat() * 2 - 1;
        if (Float.isNaN(f)) {
            System.out.println("NaN!");
        }//from  ww w.ja va2  s. c o  m
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    Random diceValues = new Random();
    System.out.println(diceValues.nextInt(6));
    System.out.println(diceValues.nextInt(6));
}