Please assist in the below code for java.
CLASS1: I've the following code in Class1:
public String getnumber()
{
return this.number;
}
CLASS2: I've another class Class2 with code set as:
Class1 cla = new Class1();
public String number_to_compute=cla.getnumber() // This is variable
CLASS3:
I've a third class class3
where I'm executing some other methods:
Class1 class1 = new Class1();
Class2 class2 = new Class2();
public static void main(String args[])
{
System.out.println(class1.getumber());
System.out.println(class2.number_to_compute);
}
OUTCOME:
In the above problem, class1.getumber()
works fine and gives correct answer where as class2.number_to_compute
outtputs null
Why is class2.number_to_compute
a null
value?