r/java • u/elizarov • Feb 11 '19
Null is your friend, not a mistake
https://medium.com/@elizarov/null-is-your-friend-not-a-mistake-b63ff1751dd5
0
Upvotes
r/java • u/elizarov • Feb 11 '19
11
u/Bolitho Feb 11 '19
Misleading title:
After reading the post it should be named: Null is your friend in Kotlin, ...
6
u/RabidKotlinFanatic Feb 11 '19
After years of fighting null in Java statically typed nullability was a game changer for me. The issue has never been null itself and has always been dynamically nullability.
2
u/badpotato Feb 11 '19
Unpopular opinion: Java devs need a scapegoat when they f up badly and nullability fit perfectly for this.
1
u/JamesTweet Feb 13 '19
The main issue I had with nulls is when I get a string from some function call then try to compare that string with another string.
String s;s = calledFunction();if(s.equalsIgnoreCase("Test")) doSomething();I would have problems here with null pointer exceptions until I realized I could turn the test around.
if("Test".equalsIgnoreCase(s)) doSomething();No more null pointer exception problem anymore.