I've written a small Java app to generate arrays randomly, with random numbers. This class works properly:
Dice.java
import java.util.*;
public class Dice {
private int i = 10;
private int value = 0;
private Random rnd = new Random();
public void roll_dice() {
int g = i;
value = rnd.nextInt(g); // Here is not make a single error.
if ((value != 0) & (value <= 6)) {
System.out.println("Number is :" + value);
} else {
System.out.println(" Error number should be between 1 and 6. Try again");
}
}
}
When I go to compile this following class, however, I get the following error:
Error cannot find symbol - method nextInt(int)
Random.java
import java.util.*;
public class Random {
private int[] number;
private int g;
private Random rnd = new Random();
public void Bicbig(int amount) {
g = amount;
if ((amount >= 1) & (amount <= 100)) {
} else {
System.out.println("Please Enter Between 1 and 100. Please try again .");
}
}
public void generate() {
number = new int[g];
int u = rnd.nextInt(g); // Error cannot find symbol - method nextInt(int)
}
}
Why am I getting this exception? How can I fix it?