public static void main(String[] args) {
// TODO Auto-generated method stub
Integer len =7;
Random random = new Random();
for(int i=0;i<1000;i++){
int r = random .nextInt(len);
System.out.println(r);
}
}
produces integers up to 7, 0, 1, 2, 3, 4, 5 , 6.
Also compare
Java: Random.nextInt() and Math. Difference of random() -
generate random numbers
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326840082&siteId=291194637
Ranking