Solution :
I read your question on this forum. I will try to explain you the solution on your issue in below answer.
I think you want to access the object which is not yet created or currently not allotted any memory.
Just follow below steps:
1.You should start Debugger and then execute the code it will directly take you to the broken code you can fix this using a new keyword at a appropriate place.
2.If database is causing this issue because your object is not present then you can do the null check and handle it.
3.if (obj == null) {
// write logic to handle null object
}
5. If your object is collected by Garbage Collector already then it is toughest situation.If you are trying to find it by name or by string and if garbage collector have already cleaned it then it will be very difficult to find the object. To avoid such situation then one should do null checks in a code and then handle it.