int randomInt ;
Random randomGenerator = new java.util.Random();
randomInt = randomGenerator.nextInt(100); // integer random range is between 0 until 100
System.out.println(randomInt );
You can also play with other data types :
System.out.println( randomGenerator.nextBoolean());
System.out.println( randomGenerator.nextDouble());
System.out.println( randomGenerator.nextFloat());
System.out.println( randomGenerator.nextLong());
System.out.println( randomGenerator.nextGaussian());
0 comments:
Post a Comment