| | |
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: 763
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 |
6 actuate android api applet application applications array arrays automation balls bank binary bluetooth bold business c++ chat class clear client code codesnippet collections component coordinates database defaultmethod development dice doctype dragging ebook eclipse educational error file formatingtextintooltipjava fractal froglogic game givemetehcodez graphics gui hql html ide ideas image infinite ingres integer intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans openjavafx parameter php problem program programming project recursion repositories scanner scrollbar sell server set sms sort sorting sql sqlserver state storm string sun superclass swing swt threads tree websites windows







