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. Thanks a lot! This really helped!!!
View Tutorial          By: SuperSeppel13 at 2009-04-14 04:25:06

2. 'Numbers' is the name of his table, you need to su
View Tutorial          By: Amir at 2010-09-15 10:59:20

3. Assalamu alaikum saaliya sir,

Could

View Tutorial          By: Jaffer sulaiman at 2014-08-23 06:01:20

4. Thanks. Well explanation..
View Tutorial          By: Ebi Divakar at 2011-07-26 04:31:30

5. Dear sir/madam

can you please show

View Tutorial          By: kgothatso at 2011-05-13 17:46:19

6. the program is writen beautifly and it is easy to
View Tutorial          By: sania cheema at 2009-05-04 12:14:19

7. i did the same thing..but it s nt working.. :(
View Tutorial          By: dEviL at 2008-12-03 10:20:31

8. it's good and very best
View Tutorial          By: rushikesh at 2014-02-04 11:28:42

9. Thanx..very useful in this pgm..
View Tutorial          By: priya at 2013-02-06 10:54:44

10. "I get an error returned saying the SMPT serv
View Tutorial          By: Dennis at 2011-06-24 10:18:10