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



Ask a Question

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. hello Ramlak I am getting Error Time Out At Step 6
View Tutorial          By: hardik at 2011-04-13 05:12:06

2. for me also The code gives the following exception
View Tutorial          By: RaghunathaReddy.P at 2009-11-06 23:40:05

3. Hey guys it's working. If not then remove p.waitFo
View Tutorial          By: dileep at 2013-01-04 19:51:38

4. very very nice...
thanks

View Tutorial          By: ramu at 2010-11-23 23:38:18

5. nice effort
View Tutorial          By: Tiger at 2011-07-06 02:17:13

6. i have a problem .
i am getting an error ca

View Tutorial          By: chaitra at 2011-11-16 07:28:29

7. please provide web.xml for this application.
View Tutorial          By: vandana at 2010-03-10 02:08:05

8. hi i need moving clock javascript code...please se
View Tutorial          By: madhavan at 2008-10-19 21:59:45

9. so if you then wanted to send this gzencoded data
View Tutorial          By: Mike at 2009-03-18 12:12:28

10. Fantastic work guys
View Tutorial          By: wizard at 2012-09-22 04:18:59