How does null work in this code?
java
Solution
Java will always try to use the most specific version of a method.
Since the call
t.doStuff(null);
is applicable to both methods
t.doStuff(Object o)
t.doStuff(String o)
Java will choose the most specific method description, which is
t.doStuff(String o)
Problem
How does null work in this code, why doesn't it print object? ``` class Test1{ public void doStuff(Object o){ System.out.println("In Object"); } public void doStuff(String o){ System.out.println("In String"); } } public class TTest { public static void main(String args[]){ Test1 t = new Test1(); t.doStuff(null); } } ``` Output: In String