Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Still not getting working of compareTo() method

 
saurabhthard aggarwal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/*WHEN COMPARETO () METHOD IS CALLED FOR ADDING THE SECOND ELEMENT IN THE TREESET WHICH OBJECT VALUE IS COMPARED TO WHICH OBJECT VALUE.
*/



 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code is very hard to understand. Please use the CODE tag when displaying code. Trying to post it normally strips the indentation and leads to character escape problems
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is unclear because of " words, so please use Code Tags [co de] [/co de]

saurabhthard aggarwal wrote:/* WHEN COMPARETO() IS CALLED FROM TREESET'S ADD() METHOD WHICH IS THE CALLING OBJECT AND WHICH IS THE CALLED OBJECT .
*/


ts1 - calling object
new Student() - called (passed) object


And as per your subject line, you asked about unable to understand compareTo(), Can you explain, What exactly you are unable to get ?

 
Ryan Beckett
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your method should look like this....





or





It is likely that the implementation of compareTo() differs across data structures. Hope that helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic