Source Code : nextDouble() and nextGaussian() in java.util.Random

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

nextDouble() and nextGaussian() in java.util.Random

    
import java.util.*;
import java.io.*;

/** Print "n" calls to nextDouble() and nextGaussian() in raw form
 * using java.util.Random.next*(); results can be plotted.
 */
public class Random4 {
  public static void main(String[] argv) throws IOException {
    // java.util.Random methods are non-static, do need to construct Math
    Random r = new Random();
    PrintWriter file1 = new PrintWriter(new FileWriter("file1"));
    PrintWriter file2 = new PrintWriter(new FileWriter("file2"));
    for (int i=0; i<10000; i++) {
      file1.println(r.nextDouble());
      file2.println(r.nextGaussian());
    }
    file1.close();
    file2.close();
  }
}

           
         
    
    
    
  

Thank with us