java 去除数组重复数据,并输出重复数据值

/**
 * 去除重复数据
 * @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);
			}
		}
	}
}


原文地址:https://www.cnblogs.com/riasky/p/3373604.html