| | |
Wat is method compareTo?
![]() |
•
•
Join Date: Jul 2006
Posts: 9
Reputation:
Solved Threads: 0
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:
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:
I assume that it does something like 'a' > 'b' and "apple" < "aardvark"
Last edited by cscgal; Jul 3rd, 2006 at 12:34 am.
•
•
Join Date: Jul 2006
Posts: 9
Reputation:
Solved Threads: 0
Ok.....But then tat is one thing tat I really don understand...
Why it giv a positive whwn it comes to
?
Why it giv a positive whwn it comes to
Java Syntax (Toggle Plain Text)
"cat" compareTo ("Cat")
•
•
Join Date: Mar 2004
Posts: 762
Reputation:
Solved Threads: 38
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.
![]() |
Similar Threads
- compiler errors wargame (Java)
- compareTo Method (Java)
- Search Method help needed!!! (Java)
- Help with casting (Java)
Other Threads in the Java Forum
- Previous Thread: Message Box Switch Statement
- Next Thread: Clearing a combobox upon selection/focus
| Thread Tools | Search this Thread |
-xlint add android api applet application array automation bank bi binary blackberry block bluetooth class client code compile compiler component database developmenthelp eclipse equation error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image infinite int j2me j2seprojects java javac javame javaprojects jetbrains jni jpanel jtable julia learningresources lego linux mac main map method mobile myregfun netbeans nonstatic notdisplaying number online pearl problem program project qt scanner screen scrollbar server set singleton sms sort sorting spamblocker sql sqlserver string superclass swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor







