wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes method invocation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "method invocation" Watch "method invocation" New topic
Author

method invocation

payal bansal
Greenhorn

Joined: May 01, 2001
Posts: 23
When i run this program, o/p is String Version. Could anyone give me the reason for this? Why Object version not get printed. I do want to know the reason for this o/p. Please help me!
1. public class Test {
2. public void method(Object o) {
3. System.out.println("Object Version");
4. }
5. public void method(String s) {
6. System.out.println("String Version");
7. }
8. public static void main(String args[]) {
9. Test test = new Test();
10. test.method(null);
11. }
12. }
Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241
Hi, Payal.
Have a look at these two links:
http://www.javaranch.com/ubb/Forum24/HTML/006183.html
http://www.javaranch.com/ubb/Forum24/HTML/008498.html
Art
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: method invocation
 
Similar Threads
null reference/JQuest question
why does it behave like that?
Strings
how to invoke the overload method when use null as argument?
Java compiler error