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. sorry guys: how can i retrieve a report or large t
View Tutorial          By: aidid at 2013-05-04 06:07:42

2. Hi All,

Can any one please let me k

View Tutorial          By: Deepak at 2015-03-19 15:24:40

3. Hi Ramlak,
I am using jdk1.4.2 to run the a

View Tutorial          By: mounika at 2008-04-27 03:05:36

4. Hi! Sir.I am anish from Sultanpur.I want to Know t
View Tutorial          By: Anish at 2014-12-10 08:23:49

5. thank you.
View Tutorial          By: lluulnw at 2014-11-22 12:39:35

6. Very good. Excellent examples and easy to understa
View Tutorial          By: Fernando Basso at 2012-09-30 22:17:56

7. Ku is quite correct. When you create any object, i
View Tutorial          By: Avnish at 2010-10-28 04:00:20

8. Nice stuff u guyzz are sharing
View Tutorial          By: kunal sharma at 2013-11-19 03:45:08

9. I am using my NOKIA 2700 via blutooth connection.
View Tutorial          By: Rahi at 2010-05-11 04:39:33

10. Sir, I need to use MS Access as a database in java
View Tutorial          By: John Moses at 2012-03-31 00:20:38