Timeline for What's the best way to avoid lots of "if (obj != null)" in Java code?
Current License: CC BY-SA 2.5
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 12, 2014 at 7:45 | comment | added | Oliver Watkins | exactly. If null checks are everywhere in the code, it shows that the code is poorly written. | |
| Jul 29, 2010 at 15:28 | comment | added | Vlad | @matt: indeed. however the check for null can be done not before using the object, but immediately after getting it. | |
| Jul 29, 2010 at 14:43 | comment | added | matt b | On the other hand, for many contracts, null is an acceptable value. So you wouldn't want to eliminate ever checking for null, only eliminate the defensive need to check everything. | |
| Jul 29, 2010 at 14:36 | history | answered | Vlad | CC BY-SA 2.5 |