2
我試着去產生與此代碼的隨機數,但經常收到此錯誤nextInt是未定義類型的方法安全隨機
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method nextInt(int) is undefined for the type SecureRandom
at SecureRandom.main(SecureRandom.java:18)
這裏就是我試圖
public class SecureRandom {
public static void main(String[] args) {
SecureRandom randomNumbers = new SecureRandom();
for (int count = 1; count <=20; count++) {
int face = 1+randomNumbers.nextInt(6);
System.out.printf(" %d" , face);
if (count %5 ==0) {
System.out.println();
}
}
}
}
'在SecureRandom.main'是您的線索。你有兩個名字完全相同的類,你認爲Java如何處理? – 2014-12-07 11:02:33