This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface Implementation

 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic