Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Two things are going on here to allow this to work. First of all, max() is 'null aware' so that [300, null, 400].max() == 400 and secondly with the ?. operator, an expression like p?.job?.salary will be equal to null if salary is equal to null, or if job is equal to null or if p is equal to null. You don't need to code a complex nested if ... then ... else to avoid a NullPointerException.

...