这里为什么用equals会错,改==就不会?java入门第一集6.8获取数组下标课后练习
public class practice_1_6_8 {
public static void main(String[] args) {
int[] cored = {11,22,33,44,55,66,77,88,99,00};
System.out.println("判断数组下标:");
for (int i = 0 ; i<cored.length;i++) {
System.out.println("数组内容:"+cored[i]);
System.out.println("对应的数组下标:");
for (int j = 0 ;j<cored.length;j++) {
if(cored[i]==cored[j]){
System.out.println(j);
}
}
}
}
}
public class practice_1_6_8 {
public static void main(String[] args) {
int[] cored = {11,22,33,44,55,66,77,88,99,00};
System.out.println("判断数组下标:");
for (int i = 0 ; i<cored.length;i++) {
System.out.println("数组内容:"+cored[i]);
System.out.println("对应的数组下标:");
for (int j = 0 ;j<cored.length;j++) {
if(cored[i].euqals(cored[j])){
System.out.println(j);
}
}
}
}
}
难道equals方法不是这样用的?