Wat is method compareTo?

Reply

Join Date: Jul 2006
Posts: 9
Reputation: zidane28 is an unknown quantity at this point 
Solved Threads: 0
zidane28 zidane28 is offline Offline
Newbie Poster

Wat is method compareTo?

 
0
  #1
Jul 3rd, 2006
As far as I know 'bout method compareTo, it compare Strings......
It return 0 when if the strings are equal.
That one I know.....
It return negative number if the string that invokes method less than the strings that pass as an argument......
It return positive number if the string that invokes method greater than the strings that pass as an argument......
BUT wat is mean by "greater than" and "less than"?
If is value than is easy to understand...
But 4 string....
Can it compare like that?:eek:
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,036
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 130
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Wat is method compareTo?

 
0
  #2
Jul 3rd, 2006
I assume that it does something like 'a' > 'b' and "apple" < "aardvark"
Last edited by cscgal; Jul 3rd, 2006 at 12:34 am.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 9
Reputation: zidane28 is an unknown quantity at this point 
Solved Threads: 0
zidane28 zidane28 is offline Offline
Newbie Poster

Re: Wat is method compareTo?

 
0
  #3
Jul 3rd, 2006
Ok.....But then tat is one thing tat I really don understand...
Why it giv a positive whwn it comes to
  1. "cat" compareTo ("Cat")
?
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 25
Reputation: DaSogo is an unknown quantity at this point 
Solved Threads: 2
DaSogo DaSogo is offline Offline
Light Poster

Re: Wat is method compareTo?

 
0
  #4
Jul 4th, 2006
look online for the ASCII character chart. It will give the character and its numerical ordering with in the chart. if a=1 and b=2, then a<b. If C=1 and c=2, then C<c. Lower case and upper case are different from one another.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 763
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: Wat is method compareTo?

 
0
  #5
Jul 7th, 2006
compareTo() takes an object and compares it to the object that called it. For strings, it simply compares the characters. For other objects, it depends on the object. How the method is implemented determines what is necessary for another object to be considered equal to it. It returns 0 if the two are considered to be equal, or less than or greater than.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC