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



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 gives strange result when we use == as delimite
View Tutorial          By: Amit at 2010-05-07 05:03:41

2. i appreciate the article for being straight to the
View Tutorial          By: shey-poun at 2011-12-14 06:39:51

3. article is good but I would have liked to get more
View Tutorial          By: Bharat Agrawal at 2010-09-25 22:18:40

4. very useful example. Thanks for this help.
View Tutorial          By: Saurabh at 2010-04-23 04:50:13

5. Hi
I am newly in java. I have one dought.

View Tutorial          By: Dinakar at 2008-07-26 01:13:08

6. How to download any file when a button is in .jsp
View Tutorial          By: Gopesh at 2012-04-13 09:35:11

7. hi ashraf , ramlak and all,
i m new here .

View Tutorial          By: hemendra at 2009-12-28 21:59:34

8. how to pass user input string (like a user entered
View Tutorial          By: saif at 2012-12-04 19:51:26

9. give some good examples very bad i dont lke dis ex
View Tutorial          By: abinaya banu at 2014-07-14 06:04:28

10. at
OK
at+cmff=1
OK
at+

View Tutorial          By: shrinivas at 2009-03-07 23:16:51