Java集合去重复元素的方法有以下几种:
List<String> list = new ArrayList<>(Arrays.asList("A", "B", "A", "C", "B"));
Set<String> set = new HashSet<>(list);
System.out.println(set); // 输出:[A, B, C]
List<String> list = new ArrayList<>(Arrays.asList("A", "B", "A", "C", "B"));
Set<String> set = new LinkedHashSet<>(list);
System.out.println(set); // 输出:[A, B, C]
List<String> list = new ArrayList<>(Arrays.asList("A", "B", "A", "C", "B"));
List<String> distinctList = list.stream().distinct().collect(Collectors.toList());
System.out.println(distinctList); // 输出:[A, B, C]
List<String> list = new ArrayList<>(Arrays.asList("A", "B", "A", "C", "B"));
List<String> distinctList = new ArrayList<>(org.apache.commons.collections4.CollectionUtils.removeAll(list, null));
System.out.println(distinctList); // 输出:[A, B, C]
以上是几种常用的去除Java集合中重复元素的方法,根据具体情况选择合适的方法即可。