x的值交换后错误了不是之前第一个元素交换后对应的下标了
// 用x来记录i=0存储元素交换后的下标的位置for(int i = 0; i < jLabels.length; i++){//打乱顺序
int j = random.nextInt(jLabels.length);
JLabel temp = jLabels;
jLabels = jLabels;
jLabels = temp;
if((x == i || x == j) && i != j){
if(x == i){x = j;}
if(x == j){x = i;}
}
}
页:
[1]