Timeline for answer to What is a NullPointerException, and how do I fix it? by L. G.
Current License: CC BY-SA 4.0
Post Revisions
20 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 23, 2022 at 13:17 | comment | added | L. G. | A very interesting checker developed by fb: engineering.fb.com/2022/11/22/developer-tools/… | |
| May 25, 2020 at 0:19 | history | edited | Ehab Qadah | CC BY-SA 4.0 |
added 218 characters in body
|
| Feb 10, 2020 at 18:06 | comment | added | dtc | Not a fan of the annotations (#3). I think human error just overcomplicates things here. | |
| Jan 26, 2020 at 3:49 | history | edited | Juan Moreno | CC BY-SA 4.0 |
Added javadoc link
|
| Aug 14, 2019 at 0:52 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
Active reading.
|
| Apr 25, 2019 at 5:27 | comment | added | Kaleem | You should write like Data_Type.valueOf(Some_Variable/view) | |
| Apr 25, 2018 at 16:38 | comment | added | bvdb |
Marking a (temporary) fieldfinal means that you can't reassign it. How can this produce/avoid a NullPointerExceptions at all ? --> conclusion: it is completely off topic.
|
|
| Dec 25, 2017 at 14:31 | history | edited | Nae | CC BY-SA 3.0 |
Improved spelling
|
| Dec 20, 2017 at 22:20 | history | edited | Peter Mortensen | CC BY-SA 3.0 |
Active reading.
|
| Nov 10, 2017 at 10:43 | comment | added | Roland |
I also use final on parameters as the instance (where it points to) should mostly (99.999% of all parameters) not be changed. Sure you can still change values.
|
|
| Oct 31, 2017 at 23:56 | history | made wiki | Post Made Community Wiki by Shog9 | ||
| Jun 28, 2017 at 9:39 | comment | added | Prasad Kamdi | A NULL pointer is one that points to nowhere or null reference. When you dereference a pointer p, you say "give me the data at the location stored in "p". When p is a null pointer, the location stored in p is nowhere, you're saying "give me the data at the location 'nowhere'". Obviously it can't do this, so it throws a NULL pointer exception. In general, it's because something hasn't been initialized properly. public void doSomething(Object obj){ //check for null if(obj != null){ //do something } else { //do something else } } | |
| May 23, 2017 at 11:47 | history | edited | URL Rewriter Bot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
| May 21, 2017 at 7:52 | comment | added | Stephen C | Read this ... before you accept these "best practices" as truth: satisfice.com/blog/archives/27 | |
| Feb 27, 2017 at 9:43 | comment | added | L. G. | IMO, it is preferable to avoid returning null objects in methods when possible and use annotation when null input parameters are not allowed in order to, by contract, reduce the amount of ´if (obj==null)´ in the code and improve the code readability. | |
| Feb 17, 2017 at 6:52 | comment | added | Lakmal Vithanage |
First thing should do is before using a nullable object, you should check whether is it null, using if (obj==null).If it is null then you should write code to handle that also.
|
|
| Jan 15, 2017 at 6:14 | history | edited | clearlight | CC BY-SA 3.0 |
added 4 characters in body
|
| Mar 5, 2016 at 10:34 | comment | added | Jan Chimiak |
It is worth mentioning that some IDEs (e.g. Eclipse) offer automatic nullity analisys based on customizable annotations (e.g. @Nullable as listed above) and warn about potential errors. It is also possible to infer and generate such annotations (e.g. IntelliJ can do that) based on existing code structure.
|
|
| Apr 17, 2015 at 12:58 | comment | added | Amaresh Pattanayak | In j2ee projects,Nullpointer exception is very common.Some cases reference variables got null values.So You should check the variable initialization properly.And during conditional statement you should always check that flag or reference contains null or not like:- if(flag!=0) { ur code that uses flag } | |
| Jun 25, 2014 at 11:17 | history | answered | L. G. | CC BY-SA 3.0 |