Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Why does being null safe matter

I'm currently in the process of switching over from java to kotlin and one of the stated advantages that keeps popping up is that kotlin is Null safe and by default cant have variables or objects be assigned a null value but there are ways to assign a null value. However I'm not sure why this is beneficial what problems arise from Java not being null safe?

Thus far online searches have only yielded descriptions of what null safety is and not why it was implemented. Thanks in advance.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No security...

  1. It's easy to forget that a member reference in your class could be null. If you use what you think is an object reference but it's actually null, you get a NullPointerException.

  2. There is no compiler-enforced way for a method to declare that it can only handle non-null parameters. The author can mark it with some annotation or put a note about it in the method documentation, but null values can still be passed and cause a NullPointerException or other exception of the author's choosing.

  3. There is no compiler-enforced way for a method to declare it and return null. The author can mention it in the documentation or add some annotation to it, but if he doesn't notice or forgets, he can try to use a null return value as an object reference and cause a NullPointerException.

  4. Code that once worked may stop working and start throwing NullPointerExceptions if a method that never returned a null value sometimes starts throwing a null value. Since the compiler doesn't enforce it, you get the exception at runtime instead of getting a compiler error so you can fix it.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!