我怎么会叫从java.util.Random
一个Random
为supertype constructor
?使用随机量和超
例如
Random rand = new Random();
int randomValue = rand.nextInt(10) + 5;
public Something()
{
super(randomValue);
//Other Things
}
当我尝试这个编译器说,我“不能引用randomValue
supertype constructor
之前一直被称为”。
答案不是线程安全的。 –
@SiyuanRen请原谅我,但是线程安全是什么意思? – Dan
@Dan:这意味着从不同线程同时构造'Something'会导致微妙的错误。 beresfordt的答案没有这个问题。 –