0
How to set random int?
2 Respostas
+ 2
I would recommend you to do it like this:
Random random = new Random();
int test = random.nextInt();
But you have to import the Random class:
import java.util.Random;
A working example:
import java.util.Random;
public class Program {
public static void main(String[] args) {
Random rand = new Random();
int test = rand.nextInt();
System.out.println("The random integer is: " + test);
}
}