I have something like this and I want to get a String as a result
List<Profile> profile;
String result = profile
.stream()
.filter(pro -> pro.getLastName().equals("test"))
.flatMap(pro -> pro.getCategory())
getCategory() should return an string but not sure what I have to use to return a string, I tried several things but any worked
Any idea?
Thanks
List<Profile> profile;
String result = profile.stream()
.filter(pro -> pro.getLastName().equals("test"))
.map(pro -> pro.getCategory())
.findFirst()
.orElse(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With