Stream Filter Property of Objects
public static void main(String[] args) {
List<User> users = Arrays.asList(
new User("Maxi",1),
new User("Priya",2),
new User("Sachin",3),
new User("Rahul",4)
);
List<String> names = users.stream()
.map(User::getName)
.collect(Collectors.toList());
names.forEach(System.out::println);
}
Output
Maxi
Priya
Sachin
Rahul
List<User> users = Arrays.asList(
new User("Maxi",1),
new User("Priya",2),
new User("Sachin",3),
new User("Rahul",4)
);
List<String> names = users.stream()
.map(User::getName)
.collect(Collectors.toList());
names.forEach(System.out::println);
}
Output
Maxi
Priya
Sachin
Rahul