[Solved] How to simplify if statement using Optional.ofNullable() [closed]
[ad_1] You can do it as follows: String section = “PRIMARY”; Optional.ofNullable(student) .map( i -> (i.getStandard() > 5) ? “SECONDARY” : section ) .orElse(section); [ad_2] solved How to simplify if statement using Optional.ofNullable() [closed]