public class Demo {
public static void main(String[] args) {
int []age = {1,2,3,4,5,6,5};
for (int i = 0; i < age.length-1; i++) {//双层循环,定住一个,再考虑下一个!
for (int j = i+1; j < age.length; j++) {
if(age[i] == age[j]){
System.out.println("有重复的!"+i+" "+j);
break;
}
}
}
}
}
|