SSISO Community

시소당

new Random

new  Random(int  intValue)

/*
  *  Output:  
First  generator:
-1193959466
-1139614796
837415749
-1220615319
-1429538713
118249332
-951589224
1301674577
-1638067850
-1279751870

  */

import  java.util.Random;

public  class  MainClass  {

    public  static  void  main(String  args[])  {
        Random  generator  =  new  Random(100);

        System.out.println("First  generator:");
        for(int  i  =  0;  i  <  10;  i++)
            System.out.println(generator.nextInt());

    }
}

--다음페이지--

Random:  nextInt()

/*
  *  Output:  
1092866141
-1813775291
-538087130
1207492102
19111874
1173765314
-795903398
1623201484
845754190
1812357378

  */

import  java.util.Random;

public  class  MainClass  {

    public  static  void  main(String  args[])  {

        Random  generator  =  new  Random();

        for(int  i  =  0;  i  <  10;  i++)
            System.out.println(generator.nextInt());
    }
}

--다음페이지--

Random:  nextGaussian()

/*
  *  Output:
0.9858761222419792
-1.0868562994825026
-1.2801148369647788
0.03988775024786847
-1.8662098370799078
-0.12277520073012224
0.0911032879532435
-0.0804314384368678
-2.3955991772544114
-1.857516970646183
  */

import  java.util.Random;

public  class  MainClass  {

    public  static  void  main(String  args[])  {
    
        Random  generator  =  new  Random();
        for(int  i  =  0;  i  <  10;  i++)  {
            System.out.println(generator.nextGaussian());
        }

    }
}

582 view

4.0 stars