<div dir="ltr"><div>Hello,</div><div><br></div><div>I think <font face="monospace">java.util.Optional</font> class should have a static method named like </div><div><font face="monospace">getOrDefault(Object o, Object default)</font></div><div><font face="monospace"><br></font></div><div>In short, if an object is null, it should return the default object, otherwise the same object. And inside, default null check should be done. Same result can be achieved by method chaining of ofNullable and orElse, but then an object is created. I think it will be memory efficient because only one static method needs to be called. I don't know if it has been discussed before. </div><div><br></div><div>Also there is <span style="font-family:monospace">Objects.requireNonNullElse(Object o1, Object o2) </span></div><div>but the second parameter should be non-null.</div><div><br></div><div>Thanks in advance..</div>
</div>