Issue
How i can do this code with stream and lambda functions, in JAVA 8:
//Replace null values with "NO"
for (Product product:
listProduct) {
if(product.getIsBreakStock().equals(null)) product.setIsBreakStock("NO");
}
I try with replaceAll function tutorial and foreach(), but IDE throw me an error:
listProduct.forEach(p ->
p.getIsBreakStock().equals(null) ? p.setIsBreakStock("NO") : p);
Required type: void Provided: Product
Solution
maybe this will help
listProduct.stream().filter(p -> p.getIsBreakStock() == null).peek(p -> p.setIsBreakStock("NO") ).collect(Collectors.toList());
Answered By - iroli Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.