package Stream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class stream {
/*public static void main(String[] args) {
//filter过滤掉 .....
List<String> strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl");
List<String> filtered = strings.stream().filter(string -> !string.isEmpty()).collect(Collectors.toList());
for (String string2 : filtered) {
System.out.println(string2);
}
}*/
public static void main(String[] args) {
user u = new user();
u.setId(1);
u.setName("ha");
u.setId(2);
List<user> l =new ArrayList<user>();
l.add(u);
//获取list里面对象里面的属性值
Set<Integer> Inted = l.stream().map(ls->ls.getId()).collect(Collectors.toSet());
}
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class stream {
/*public static void main(String[] args) {
//filter过滤掉 .....
List<String> strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl");
List<String> filtered = strings.stream().filter(string -> !string.isEmpty()).collect(Collectors.toList());
for (String string2 : filtered) {
System.out.println(string2);
}
}*/
public static void main(String[] args) {
user u = new user();
u.setId(1);
u.setName("ha");
u.setId(2);
List<user> l =new ArrayList<user>();
l.add(u);
//获取list里面对象里面的属性值
Set<Integer> Inted = l.stream().map(ls->ls.getId()).collect(Collectors.toSet());
}
}