59.0k views
1 vote
How to solve "You cannot call a method on a null-valued expression" error

User Scarnet
by
4.7k points

1 Answer

0 votes

You have an object declared in the function which has a undeclared value.

Step-by-step explanation:

if you will make a variable of class or object in JAVA or other reference typed languages and will not assign the value to it this error occurs.

For example :

obj object; // this line declares a object named variable of type obj class

Here it will cause same error iff i will do it like :

obj = object = new obj();

User Phani Kumar M
by
5.2k points