+ 6
Java
function for random value in java.is there any????
4 Answers
+ 12
//import class package.
import java.util.Random;
//main(Start of program).
//Creating a instance of class Random.
Random rnd = new Random();
//Generate a number from 0 - 9.
int number = rnd.nextInt(10);
//Prints the value of the assigned interger.
System.out.println(number);
+ 12
// main(Start of program)
// Generate a number from 0 - 9
int number = Math.random() * 10;
// Prints 'number'
System.out.println(number);
/* Although this is also an option, I highly recommend you to use what D_Stark has shown */
+ 3
can we use random class for inputting values??