List initialization
List<String> name = Arrays.asList("xxx","yyy","zzz"); //or List<String> name =new ArrayList<>(Arrays.asList("xxx","yyy","zzz"));
However, in this case, the size of the list will be fixed, and it cannot be added any more, so be careful.
List remove duplicates
List<String> list = Arrays.asList("abc", "hello", "hello", "world"); List<String> distinctList = list.stream().distinct().collect(Collectors.toList()); System.out.println(String.join(",", distinctList));
output abc,hello,world