Your code, as typed above, will NOT work.
============
/**
* Created on Sep 16, 2008, 8:18:05 PM
*/
public class TestNull {
public void callMethod(Object obj) {
System.out.println("hi");
}
public void callMethod(String s) {
System.out.println("By");
}
public static void main(String[] args) {
TestNull i = new TestNull();
i.callMethod(null);
Object obj = new Object();
i.callMethod(obj);
}
}
//////////////////
$> run-single:
By
hi
===============
Because I made an Object of type TestNull in main, I get state, values, and methods. The JRE will put an object on the heap something like this:
[$a$1h[TestNull::i[callMethod[String]:null::callMethod[Object]:null]]
consider:
static int i; // will equal 0
static double d; or static float f; // will equal 0.0f
static Object obj; // will equal null
static String s; // will equal null
static boolean b; // will equal false
the keyword static will init the value of a var FIRST when making any Object. If there is no assignment operator (=) then the JRE will use the defaults mentioned above