MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/1r7iv5p/objectsrequirenonnullelse/o62gzmb/
r/java • u/edurbs • Feb 17 '26
I must have been living in a cave. I just discovered that this exists.I can code
City city = Objects.requireNonNullElse(form.getCity(), defaultCity);
... instead of:
City city = form.getCity();
if(city == null){
city = defaultCity;
}
136 comments sorted by
View all comments
Show parent comment
2
you can put a breakpoint on this though..? it isnt a special construct.
-1 u/[deleted] Feb 19 '26 [removed] — view removed comment 2 u/vips7L Feb 19 '26 I don’t really think you know what functional programming is. 1 u/nekokattt Feb 19 '26 if you are debugging the behaviour of the JDK itself rather than just looking at what it returns, that feels like you don't really understand what you are trying to debug
-1
[removed] — view removed comment
2 u/vips7L Feb 19 '26 I don’t really think you know what functional programming is. 1 u/nekokattt Feb 19 '26 if you are debugging the behaviour of the JDK itself rather than just looking at what it returns, that feels like you don't really understand what you are trying to debug
I don’t really think you know what functional programming is.
1
if you are debugging the behaviour of the JDK itself rather than just looking at what it returns, that feels like you don't really understand what you are trying to debug
View all comments
Show parent comment
2
u/nekokattt Feb 18 '26
you can put a breakpoint on this though..? it isnt a special construct.