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

Java program to get location meta data from an image

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

Archived Comments

1. I got error during using above code if There is ne
View Tutorial          By: Sunil at 2009-12-28 05:22:45

2. super explanation
View Tutorial          By: pree at 2013-12-30 16:41:32

3. Great stuff, learned more from this example than r
View Tutorial          By: David Bandelin at 2011-03-22 07:10:38

4. good one
View Tutorial          By: saurabh at 2012-01-17 04:43:29

5. hi
this is helpful, but file store it in m

View Tutorial          By: Mahesh at 2011-11-10 06:52:39

6. Excellent example Jagan. By the way I have a quest
View Tutorial          By: Shrihas at 2012-01-07 14:12:48

7. Thankyou very much for the explanation
View Tutorial          By: Ruchita at 2010-11-11 01:16:10

8. Good one......
Thanks.

View Tutorial          By: Suresh at 2013-03-14 07:38:45

9. The tutorial is simple and clear.
@Gnani, i

View Tutorial          By: Tayo at 2010-01-03 13:10:24

10. HI Friends,

I am new to java and i

View Tutorial          By: Srini at 2015-04-05 17:00:58