Please consider this short code :
class abs{}
class cd
{
static void method(abs a)
{
System.out.println(a); // PRINTS NULL
a = new abs();
System.out.println(a); // PRINTS NEWLY GENERATED HASHCODE
}
public static void main(String...args)
{
abs gh = null;
// REFERENCE SET TO NULL
// NOW PASSING IT TO A METHOD
method(gh);
// IF OBJECT CALL IS CALL BY REFERNCE, THEN WHY DOES THIS PRINT NULL ?
System.out.println(gh);
}
}
My comments explain what I want. Basically the last print statement should print the hashcode but it prints 'null'. What is the reason behind this ?