我无法理解的是如何确切的方法如
public interface MouseListener extends EventListener {
public void mouseClicked(MouseEvent e) {
//code for what happens when you click the mouse on the component
}
}
Run Code Online (Sandbox Code Playgroud)
知道鼠标事件的id.为什么在执行事件时事件仅发送到mouseClicked方法?这些方法的构造函数需要任何可能的鼠标事件,所以当其他方法具有相同的构造函数(即mousePressed,mouseReleased等)时,为什么它只被发送到mouseClicked方法
如果数组填充如下:
for (int i = 0; i < rand.length; i++) {
rand[i] = (int) Math.round(Math.random() * 1000000) + 1;
}
Run Code Online (Sandbox Code Playgroud)
然后使用Arrays.sort或任何排序算法进行排序,如果有的话
int sum = 0;
for(int i = 0; i < rand.length;i++) {
if (i % 2 == 0) {
sum += rand[i] + rand[rand.length - 1 -i];
}
else
sum -= rand[i] + rand[rand.length - 1 - i];
}
System.out.println("\n");
System.out.println(sum);
Run Code Online (Sandbox Code Playgroud)
然后总和将始终为零.这已经证明了我已经测试过它的一百次左右.尝试任何范围,任何数组长度.
我无法想象伪随机性真的会有缺陷.这里发生了什么?