Hi,
The below program behaves as follows. As it is, it prints the object value of "it" within the function g() as some valid value. Once I replace the commented //it.g() and make it uncommented and comment the next line g(), the value of "it" is null. can some one explain me this behavior ?
thanks,
krishna
import java.io.*;
import java.util.*;
public class InstanceTest {
InstanceTest it;
public void f() {
it = new InstanceTest();
System.out.println("it value is " + it);
//it.g();
g();
}
public void g() {
System.out.println("it value is " + it);
}
public static void main(String[] args) {
InstanceTest it1 = new InstanceTest();
it1.f();
}
}
The below program behaves as follows. As it is, it prints the object value of "it" within the function g() as some valid value. Once I replace the commented //it.g() and make it uncommented and comment the next line g(), the value of "it" is null. can some one explain me this behavior ?
thanks,
krishna
import java.io.*;
import java.util.*;
public class InstanceTest {
InstanceTest it;
public void f() {
it = new InstanceTest();
System.out.println("it value is " + it);
//it.g();
g();
}
public void g() {
System.out.println("it value is " + it);
}
public static void main(String[] args) {
InstanceTest it1 = new InstanceTest();
it1.f();
}
}