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. Program is good and easy to understand
View Tutorial          By: sravs at 2011-05-16 00:45:05

2. Good and Effective example
thank you

View Tutorial          By: Perumal Naren at 2009-12-30 03:10:50

3. awesome example
View Tutorial          By: jagjyot singh at 2010-01-12 20:39:04

4. Hi
I need a javafx code which I
1

View Tutorial          By: HNO11 at 2011-03-26 08:59:03

5. Thanks for a nice article !!!
View Tutorial          By: Piyush Sharma at 2011-12-15 12:24:06

6. it's very good example to understands overloading
View Tutorial          By: Rakesh Sharma at 2011-11-18 06:37:49

7. Oh, Thanks for your code, but I think you should a
View Tutorial          By: Songokute at 2013-01-29 13:55:13

8. Shouldn't you call free() on the allocated memory
View Tutorial          By: Ritchie at 2012-05-09 14:14:49

9. Hi IDK,
You close any applications includin

View Tutorial          By: Steven at 2008-12-30 03:14:33

10. its working... thanks.. thank you very much...!!!!
View Tutorial          By: Viswanathan at 2008-08-18 06:54:09