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. very well to understand
View Tutorial          By: Siva Krishna N at 2007-02-16 23:06:07

2. i tried, the coding dont hv any errors but its not
View Tutorial          By: anna at 2010-11-02 21:56:27

3. I have copied c:\php\bin\msvcr80.dll to C:\Program
View Tutorial          By: agt at 2009-10-11 09:24:06

4. import gnu.io.*;
import java.io.*;
<

View Tutorial          By: Anonymous at 2013-03-29 02:39:00

5. Unable to understand all the points, quiet confusi
View Tutorial          By: KB at 2015-04-15 10:11:14

6. i have connected my phone through bluetooth and us
View Tutorial          By: nikitha at 2013-02-05 09:07:34

7. Good work, IT really help me a lot;
View Tutorial          By: TUSHAR at 2010-02-03 01:25:37

8. I did not understand it. please give one example e
View Tutorial          By: farhaan at 2008-03-20 12:06:11

9. just looking for it, useful!
View Tutorial          By: ymfeng at 2009-03-20 00:09:56

10. In the 2nd example ,during the creation on object
View Tutorial          By: priyanka thakur at 2011-08-29 20:24:16