日期:2014-05-20 浏览次数:20657 次
int[] arr = {10,20,45,20,10,50,50}; for(int i=0;i<arr.length;i++) { int tmp =arr[i]; for(int j=i+1;j<arr.length;j++) { if(arr[j]==tmp) { System.out.println(i); System.out.println(j); break; } } }
------解决方案--------------------
String[] arr = {"10","20","45","20","10","50","50"}; int count = 0; System.out.println("重复数据索引:"); for(int i = 0; i < arr.length; i++){ for(int j = 0; j < arr.length; j++){ if(arr[i] == arr[j]){ count++; } } if(count > 1){ System.out.println(i); count = 0; } }