job01


import java.util.HashSet;

/*已知数组信息如下:
{2.2,5.5,6.6,2.2,8.8,1.1,2.2,8.8,5.5,2.2,6.6}
请使用代码找出上面数组中的所有的数据,要求重复的数据只能保留一份;
**要求:**
使用HashSet集合实现;
**效果:***/
public class job01 {
public static void main(String[] args) {
double[] dou={2.2,5.5,6.6,2.2,8.8,1.1,2.2,8.8,5.5,2.2,6.6};
HashSet<Double> hashSet=new HashSet<>();
for (int i = 0; i < dou.length; i++) {
hashSet.add(dou[i]);
}
System.out.println(hashSet);
}
}
原文地址:https://www.cnblogs.com/xiaofeiji/p/13459007.html