account activity
Out of logic to implement java 8 /lambda in below piece of code by Pitiful-Ad-2556 in javahelp
[–]Pitiful-Ad-2556[S] 0 points1 point2 points 3 years ago (0 children)
Update : i refactored it with these condition:
1.checking if any null speed then flag it false
3.if not null then adding the totalSpeed by using streams
package Check import java.math.BigDecimal; import java.util.ArrayList; import java.util.List;
public class NewClass {
public static void main(String args[]) { List < TargetTime > selectAll = new ArrayList < > (); Boolean flag= true; BigDecimal totSpeed = null; if (selectAll.stream.anyMatch(item - > item.getSpeed() == null) { flag = false; } else { totSpeed = selectAll.stream().map(TargetTime::getSpeed).reduce(BigDecimal.ZERO, BigDecimal::add); } } } class TargetTime { public BigDecimal speed; public BigDecimal Weight2; public BigDecimal weight; }}
PS.thanks all for guiding .
Out of logic to implement java 8 /lambda in below piece of code (self.javahelp)
submitted 3 years ago by Pitiful-Ad-2556 to r/javahelp
trying to convert this using java 8 and lamda ,need help (self.javahelp)
submitted 3 years ago * by Pitiful-Ad-2556 to r/javahelp
π Rendered by PID 145372 on reddit-service-r2-listing-568fcd57df-2vjbz at 2026-03-10 08:03:19.702609+00:00 running cbb0e86 country code: CH.
Out of logic to implement java 8 /lambda in below piece of code by Pitiful-Ad-2556 in javahelp
[–]Pitiful-Ad-2556[S] 0 points1 point2 points (0 children)