我在 Java 中有两个字符数组:
orig_array
和mix_array
。我需要检查它们是否不相等。
这是我到目前为止所拥有的:
sample data
orig_team=one
mix_team=neo
while(!Arrays.equals(mix_team, orig_team))
{
if (Arrays.equals(mix_team, orig_team))
{
System.out.println("congradulations! you did it");
System.exit(0);
}
else {
System.out.println("enter the index");
Scanner scn = new Scanner(System.in);
int x = scn.nextInt();
int y = scn.nextInt();
char first=mix_team[x];
char second=mix_team[y];
mix_team[x]=second;
mix_team[y]=first;
for (int i = 0; i < mix_team.length; i = i + 1)
{
System.out.print(i);
System.out.print(" ");
}
System.out.println();
System.out.println(mix_team);
}
}
如何确定两个数组是否相等?