我有整数数组:
int[] arrA = {1,2,3,4,5,6,7,8,9};
int[] arrB1= {7,3,4,1,5,8,9,2,6};
int[] arrB2= {9,5,1,4,7,6,8,2,3};
int[] arrB3= {4,6,1,3,8,9,5,7,2};
int[] arrB4= {2,3,1,5,8,9,4,6,7};
int[] arrB5= {1,2,3,4,5,6,7,8,9};
Run Code Online (Sandbox Code Playgroud)
并将所有arrBs添加到列表中,如下所示:
List<int[]> list= new ArrayList<int[]>();
list.add(arrB1);
list.add(arrB2);
list.add(arrB3);
list.add(arrB4);
list.add(arrB5);
Run Code Online (Sandbox Code Playgroud)
我想比较数组arrA与数组列表的相等性,并使用此代码完成它:
boolean isEqual=false;
for(int index=0; index<list.size(); index++){
if(list.get(index).equals(arrA)){
isEqual=true;
}
System.out.println(isEqual);
}
Run Code Online (Sandbox Code Playgroud)
我知道这arrB5是等于arrA但为什么我总是弄错?我正在进行比较吗?
我试图制作一个8益智游戏,我的问题是,当x1的值让一个特定图像的x位置的70增加直到它达到170然后它将递减直到它再次达到70,但这个减少没有工作,图像不再移动到原来的位置,但它只是颤抖.为什么会发生这种情况.为了澄清所有这些内容,您可以查看下面的代码:
run.java
public class run extends Applet implements Runnable{
public Image im;
public int x1=70, y1=70;
public int x2=170, y2=70;
public int x3=270, y3=70;
public int x4=70, y4=170;
public int x5=170, y5=170;
public int x6=270, y6=170;
public int x7=70, y7=270;
public int x8=170, y8=270;
public int x9=270, y9=270;
public Image offscreen;
public Graphics d;
public BufferedImage container;
public BufferedImage[] tile = new BufferedImage[10];
private File loadThis;
public void combi1(){
if(x1<170 && x1>=70){
x1+=1; y2+=1; x5-=1; y4-=1;
return;
}
if(x1>=70){
x1-=1; …Run Code Online (Sandbox Code Playgroud)