java 实现数组去重(集合转换)
public static void main(String[] args) { int[] nums = { 5, 6, 6, 6, 8, 8, 7 }; List<Integer> numList = new ArrayList<Integer>(); for (int i : nums) numList.add(i); Set<Integer> numSet = new HashSet<Integer>(); numSet.addAll(numList); System.out.println(numSet); }
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了