Write a program to generate random numbers in java.
Example: Generate a random numbers between 10 and 20.
Input: min=10, max=20
Output: Any number between range 10 to 20
Approach
Java
import java.util.Random;public class Main{public static void main(String[] args) {Random random = new Random();int min=10;int max=20;System.out.println("random integet between 10 and 20:"+(random.nextInt(max-min)+min));}}
No comments:
Post a Comment