tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Uncommons Maths > Java Random Number Generator

Java Random Number Generator 

Uncommons Maths is a java library with nice math utilities and random number generators. This requires the library uncommons-maths-1.2.2.jar to be in classpath. The following example shows using JavaRNG class.

File Name  :  
com/bethecoder/tutorials/uncommons/JavaRNGTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.uncommons;

import java.util.Arrays;

import org.uncommons.maths.random.JavaRNG;

public class JavaRNGTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    JavaRNG rand = new JavaRNG();
    System.out.println(Arrays.toString(rand.getSeed()));
    
    System.out.println(rand.nextInt());
    System.out.println(rand.nextDouble());
    System.out.println(rand.nextGaussian());
    System.out.println(rand.nextBoolean());
    
  }

}
   

It gives the following output,
[78, -5, 86, 69, 0, -18, 73, -18]
1740698033
0.692730311461731
1.1374133574192549
false



 
  


  
bl  br