import java.util.Random;
/**
* How to generate Random numbers in Java
*
*/
public class MainClass {
public static void main(String[] args){
Random random = new Random();
int randomNo = random.nextInt();
System.out.println("Random number is: " + randomNo);
int randomNo2 = random.nextInt(5);
System.out.println("Random number generated between 0 and 4 is: " + randomNo2);
}
}
/**
* How to generate Random numbers in Java
*
*/
public class MainClass {
public static void main(String[] args){
Random random = new Random();
int randomNo = random.nextInt();
System.out.println("Random number is: " + randomNo);
int randomNo2 = random.nextInt(5);
System.out.println("Random number generated between 0 and 4 is: " + randomNo2);
}
}
No comments:
Post a Comment