aspose file tools*
The moose likes Beginning Java and the fly likes Interface Implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interface Implementation" Watch "Interface Implementation" New topic
Author

Interface Implementation

Donald R. Cossitt
buckaroo
Ranch Hand

Joined: Jan 31, 2003
Posts: 401

From the console I would type "Donald Cossitt". Though the correct answer is given I know that what is desired is to call Person.comparTo(). I know this is not happening because the compiler is not giving me static about calling a non-static method in a static context (main). So evidently the String.compareTo() method is being called? And if so, why isn't Person.compareTo() being called? Or is there yet a layer of armor in this thick head that requires penetration?


doco
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
'tis calling Person.compareTo() and the Person.compareTo() is using String.compareTo().
You have created two objects me and son and compareTo() is being invoked on the me object.
The code works (could be more readable around the return region though - I recommend using if)
Mind you, I am half asleep this morning...
-B


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface Implementation