+ 5
Math.random()
Is the following line creates random number from 0 to 9 int n=(int)(Math.random*10);
2 Answers
+ 6
Hey, import java.util.*; outside your class and use the following.đ
int r = new Random().nextInt(10);
System.out.print(r);
+ 1
@D_Stark
If you know you are using only Random class from util package, it is best practice to import only the Random class. For example: import java.util.Random;
To summarize, import only the packages you need.