Can I skip certain operations on the first stream in a lambda expression? For example
List<BeanClass> fetch = getBeanClsss();
BeanClass bean = fetch.stream().reduce(newBean, (p1,p2)-> {
p1.setVal(p1.getVal() + p2.getVal());
// if first element skip
// else
p1.setValNum(p1.getValNum() + p2.getValNum());
return p1;
});
At first element, I do not want to run p1.setValNum method but p1.setVal method to run. So I want to do everything method except the first one.