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. Hi thanks for the example for overriding toString(
View Tutorial          By: Reshma at 2011-05-11 10:46:08

2. hi, the code is fine. i want this array to be decl
View Tutorial          By: deepi at 2012-04-26 06:08:36

3. Hi Steven. It looks like your example program does
View Tutorial          By: Ben Hallinan at 2008-04-25 08:36:42

4. very nice notes we are easy to understand this not
View Tutorial          By: maalu at 2013-04-29 07:06:56

5. it's very usefull to the users who were in startin
View Tutorial          By: Harichandana at 2013-02-28 04:37:17

6. EXACTLY COPIED BY "C PROGRAMMING" by DEN
View Tutorial          By: Aashish at 2012-06-06 17:56:36

7. Your solution has really helped me and educated me
View Tutorial          By: Tziq at 2011-01-25 08:06:06

8. Thank you Sir.
View Tutorial          By: Dinesh at 2015-08-25 10:41:30

9. Friends i m getting error while intrepreting the e
View Tutorial          By: Hanuman at 2014-02-04 14:14:00

10. im beginning to design a program that will deactiv
View Tutorial          By: andrew at 2012-01-29 14:32:39