private static void test(List<String> testList) {
List<String> arrayList = new ArrayList<>(new HashSet(testList));
}
这段代码定义了一个名为test的方法,它接受一个String类型的列表testList作为参数。方法内部,首先使用HashSet来消除列表中的重复元素,然后将结果转换为一个新的ArrayList。这样,arrayList就包含了无重复元素的集合。
private static void test(List<String> testList) {
List<String> arrayList = new ArrayList<>(new HashSet(testList));
}

被折叠的 条评论
为什么被折叠?