/**
* 去除重复数据
* @author Sunqinbo
*/
public class RemoveDuplicateData {
public static void main(String[] args) {
Integer[] a = new Integer[] { 1, 4, 5, 2, -6, 5, 9, 10, 10 }; Set<Integer> set = new HashSet<Integer>();
for (int i = 0; i < a.length; i++) {
boolean b = set.add(a[i]);
if (!b) {
System.out.println("重复数据:" + a[i] + " 索引位置:" + i);
}
}
}
}
05-02 11:29