the code is :
interface I {
int i = 0;
void display();
}
class A implements I {
I i1;
public static void main(String[] args) {
A a = new A();
a.display();
}
public void display() {
System.out.println(i1); //1
System.out.println(i1.i); //2
}
}
The output of the code is
null
0
But when the address of the i
is null
, then in the 2nd i1.i
how does it return a value ?
How can a null reference be used to point to a variable ?