Although both methods are applicable to your situation (both can accept null as a parameter), the most specific method will be called, or in other words, the method that is "closer" to the argument that you specify. Since a parameter in printValue(String ob) can be passed to printValue(Object ob) also, but not vice versa, then the printValue(String ob) is more specific and that is why it is called. The same rule applies to primitives too. For instance, check the following code:
The most specific method is called depending on the arguments.
Hope this helps!
Joined: Oct 13, 2005
It’s in the Java Language Specification (JLS); look for the links to §15.12, too. Note this is a complicated subject, even by the standards of the JLS.