Java 从数组中删除重复项
如何从数组中删除重复项
将数组转换为 Set 以删除重复项:
示例
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) {
Integer[] numbers = {1, 2, 2, 3, 4, 4, 5};
Set<Integer> unique = new HashSet<>(Arrays.asList(numbers));
System.out.println(unique);
}
}

