Activity › Forums › Salesforce® Discussions › de-reference a null object
-
de-reference a null object
Posted by chanchal kumar on August 30, 2018 at 11:49 AMwhat is “de-reference a null object” error in Apex?
shariq replied 7 years, 9 months ago 4 Members · 3 Replies -
3 Replies
-
Hello Chanchal,
This error is caused by a line of code that is trying to use an object that has not been instantiated, or an object’s attribute that has not been initialized.
NOTE: If the field Site was left empty, it will generate the error message as well.
Thanks.
Parul
- [adinserter block='9']
-
Hi Chanchal,
This is the equivalent of the Null Pointer Exception in Java.
This error is caused by a line of code that is trying to use an object that has not been instantiated, or an object’s attribute that has not been initialized.
Hope this helps.
Thanks.
-
Hi,
Mostly this error occurs when you have not initialize the list/set/map etc and using their methods.
When you query any sobject with no records and then using its fields somewhere in code without null or empty check
Hope this helps.
Log In to reply.