Java by API/org.apache.commons.math/RandomUtils

Материал из Java эксперт
Перейти к: навигация, поиск

RandomUtils.nextDouble()

   <source lang="java">

/* Random double >>> 0.9454382405994292 Random float >>> 0.21482907 Random int >>> 1521164877

*/

import org.apache.rumons.lang.math.RandomUtils; public class MathUtilsTrial {

 public static void main(String[] args) {
   // Random Value Generation
   System.out.println("Random double >>> " + RandomUtils.nextDouble());
   System.out.println("Random float >>> " + RandomUtils.nextFloat());
   System.out.println("Random int >>> " + RandomUtils.nextInt());
 }

}

      </source>
   
  
 
  



RandomUtils.nextFloat()

   <source lang="java">

/* Random double >>> 0.9454382405994292 Random float >>> 0.21482907 Random int >>> 1521164877

*/

import org.apache.rumons.lang.math.RandomUtils; public class MathUtilsTrial {

 public static void main(String[] args) {
   // Random Value Generation
   System.out.println("Random double >>> " + RandomUtils.nextDouble());
   System.out.println("Random float >>> " + RandomUtils.nextFloat());
   System.out.println("Random int >>> " + RandomUtils.nextInt());
 }

}

      </source>
   
  
 
  



RandomUtils.nextInt()

   <source lang="java">

/* Random double >>> 0.9454382405994292 Random float >>> 0.21482907 Random int >>> 1521164877

*/

import org.apache.rumons.lang.math.RandomUtils; public class MathUtilsTrial {

 public static void main(String[] args) {
   // Random Value Generation
   System.out.println("Random double >>> " + RandomUtils.nextDouble());
   System.out.println("Random float >>> " + RandomUtils.nextFloat());
   System.out.println("Random int >>> " + RandomUtils.nextInt());
 }

}

      </source>