Generate random Number

Write a program to generate random numbers in java.

Example: Using the random class in java 

Approach

Java

import  java.util.Random;

public class Main
{
  public static void main(String[] args) {
      Random random = new Random();
      System.out.println("random integet:"+random.nextInt());
        //random double 
      random.nextDouble();
      //random boolean
      random.nextBoolean();
  }

No comments:

Post a Comment