Are Explicit Null Checks Ok In Java?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • J4v1ng
    New Member
    • Feb 2022
    • 1

    Are Explicit Null Checks Ok In Java?

    What are your thoughts about explicitly checking for null in Java or other language that allows nulls? There are some alternatives but I don't know what think of it. I read an article recently(linked below), that suggests to throw exceptions, using Optional and other ...

    Is there any case that would justify the usage of null checks?
    I feel like checking for null is bad design but if so, why Java allows it in first place?
    Please let me know your thoughts.

  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

    #2
    What are your thoughts about explicitly checking for null in Java or other language that allows nulls? There are some alternatives but I don't know what think of it. I read an article recently(linked below), that suggests to throw exceptions, using Optional and other ...

    Is there any case that would justify the usage of null checks?
    I feel like checking for null is bad design but if so, why Java allows it in first place?
    Please let me know your thoughts.

    [link]
    Sounds like bait to get clicks and generate traffic.

    If you have a non-generic and specific query, support your point with research and post the specific code you're referring to.

    Comment

    Working...