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. Tnx. Very fast learning i think.
Just make

View Tutorial          By: mahdi at 2011-07-09 20:20:39

2. This code works for me. But i have a doubt how to
View Tutorial          By: Daya at 2015-05-04 12:04:19

3. Your output is not correct.. Give the correct out
View Tutorial          By: Surendrakumar at 2014-06-04 07:00:16

4. i have completed B.Tech,i want to SCJP exam ,tell
View Tutorial          By: bmnaidu at 2013-04-12 16:56:48

5. Excellent !...That explains my long-term question
View Tutorial          By: Vineeth at 2012-02-01 03:50:21

6. This tutorial is good for beginners. If you provid
View Tutorial          By: Sateesh Bobby at 2008-12-09 23:56:18

7. it was nice and helpful for me.
View Tutorial          By: mayank at 2015-03-01 08:35:48

8. Thanks a lot !
View Tutorial          By: Kalander bava ta at 2012-11-04 08:07:15

9. Hello, I have executed the above code and it works
View Tutorial          By: Sana at 2010-02-01 03:50:18

10. Interfaces contains all abstract methods(with out
View Tutorial          By: Mahesh at 2012-11-09 06:14:47