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
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.
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. hi I am execute this code But message can't send <
View Tutorial          By: Sudhir Patil at 2011-02-01 10:28:28

2. Hii... pls how can I create a aerver with an inter
View Tutorial          By: WAZIRI at 2010-03-16 11:12:11

3. Hello there , i am unable to understand read and w
View Tutorial          By: deepak at 2014-12-10 14:04:42

4. Hi,

I alos faced the same problem o

View Tutorial          By: prasanna kumar v at 2010-05-15 02:55:59

5. Thank you
View Tutorial          By: vbulletincoder at 2011-09-13 13:16:40

6. This is very clear and explains the concepts in a
View Tutorial          By: Reite at 2011-02-18 13:55:07

7. i want code to Migration from IPV4 to IPV6 at appl
View Tutorial          By: i want code , can you send me at 2015-01-23 14:38:48

8. class Foo implements Runnable{

View Tutorial          By: DeeNKHAN at 2013-03-02 06:54:13

9. excellent, very clear, thx!!!
View Tutorial          By: ma at 2010-04-07 07:42:47

10. hi all !

This is the error im getti

View Tutorial          By: Ajit at 2010-02-17 23:09:47