1.快速创建Set方法:
一、HashSet<String> set = new HashSet<String>() {
{
add("a");
add("b");
add("c");
}};
二、import com.google.common.collect.Sets;
HashSet<Integer> set = Sets.newHashSet(1,2);
三、Set<Long> ids = list.stream().map(dataInfo::getId).collect(Collectors.toSet());
2.快速创建List方法:
一、List<string> list = new ArrayList<string><string>();
list.add("string1");
list.add("string2");
二、List<string> list = new ArrayList<string>(){
{
add("string1");
add("string2");
}};
三、import com.google.common.collect.Lists;
ArrayList<Integer> integers = Lists.newArrayList(1, 2);
四、List<Long> ids = list.stream().map(dataInfo::getId).collect(Collectors.toList());