Comment on Tutorial - compareTo( ) in Java By Mashoud



Comment Added by : Azher

Comment Added at : 2010-01-29 12:23:39

Comment on Tutorial : compareTo( ) in Java By Mashoud
@Adam:
CompareTo returns the difference of the ASCII codes of the first non-matching character. So,

out.print(sOne.compareTo(sTwo)); would display
// (sTwo - sOne)
('a' - 'e') which is -4.
and
out.print(sTwo.compareTo(sOne)) would display
//(sOne - sTwo)
('e' - 'a') which is 4.

Hope this will help you.


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. "For example, float can be useful when repres
View Tutorial          By: rangzen at 2014-03-28 09:31:47

2. hi,
plz help me i cannot find the way out o

View Tutorial          By: Yash at 2008-05-07 16:59:20

3. i've run d program and its works
View Tutorial          By: okeaghala nneka at 2012-03-31 10:58:13

4. Thanks a lot.. it made my concepts of memmove,mems
View Tutorial          By: Rimmi Jain at 2009-07-23 06:42:01

5. Life-saving post, man!
(In my case i had II

View Tutorial          By: Julianno Jungle at 2013-06-28 18:32:03

6. Please help me send sms. I did everything , But no
View Tutorial          By: Prabhash V S at 2009-06-03 06:40:55

7. Nice one really helpful thanks
View Tutorial          By: Shashikant at 2012-01-06 12:00:45

8. Your explanation is good but, it will be better i
View Tutorial          By: Jabaraj at 2010-03-22 06:02:33

9. Thanks, It's exactly. A my friends has the same is
View Tutorial          By: Slim at 2012-09-29 02:52:12

10. for(i=0;i<10;i++)
for(j=0;j<90;j++)
View Tutorial          By: karthikeyan at 2012-05-23 05:33:10