I have written code to find the latest date from a list of an object that contains Date variable.
list.stream().map(segment -> segment.lastLoad).filter(x->x!=null).max(Date::compareTo).get()
But I am getting sonar issue stating
Replace this lambda with method reference 'Objects::nonNull'.
What I am not able to figure out is where can I use Method reference stated by sonar lint issue.