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. It is a good tutorial but I think the "Instru
View Tutorial          By: Jaypee at 2010-10-10 22:40:50

2. FILE:- lpton.pl......
.....................

View Tutorial          By: Prats at 2013-02-02 17:33:40

3. thnks for the loop
View Tutorial          By: Benavidez,Jam at 2010-02-02 01:57:48

4. Best example to explain Inheritance. thankyou for
View Tutorial          By: Suresh Lilhare at 2010-05-14 09:10:27

5. simple explanation,.. Nice....
View Tutorial          By: Gopi at 2011-08-19 09:28:47

6. hi, IF ANY ONE REALLY INTRESTED TO RUN THIS PROGRA
View Tutorial          By: sunil kumar sahu at 2010-10-09 11:50:56

7. Good article..
View Tutorial          By: Sudarshan at 2011-03-28 02:57:53

8. Hi guys
i am a beginer in java.. pls help

View Tutorial          By: Jeevan at 2009-12-19 09:35:06

9. what about the access modifiers, while talking abo
View Tutorial          By: Seetha at 2010-06-04 01:14:02

10. Showing code with quote tags is pretty rubbish. :/
View Tutorial          By: Daniel Jonsson at 2011-09-01 14:01:04