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 sir
how can i get started if i want to

View Tutorial          By: simiyu at 2014-03-15 09:13:04

2. thanks for this example but i want the whether th
View Tutorial          By: Rupesh Chavan at 2010-03-14 07:36:31

3. can any one plz tell me which java comm api do we
View Tutorial          By: GAURAV MODI at 2010-01-29 02:12:13

4. The sample code was all I needed to figure out how
View Tutorial          By: David at 2011-08-28 07:34:28

5. Plz can u give me some more examples of recursion.
View Tutorial          By: Asadullah at 2010-01-23 06:38:58

6. Please don't use DataInputStream to read text. Unf
View Tutorial          By: Peter Lawrey at 2013-01-30 23:46:47

7. I did all steps, but it only shows the first pictu
View Tutorial          By: behzad at 2012-07-15 16:32:41

8. Good example. However as someone said, it would be
View Tutorial          By: Neo Cambell at 2010-03-10 11:02:06

9. very simple explanation......
easily unders

View Tutorial          By: saurabh at 2009-04-17 16:02:30

10. This tutorial is really fantastic.It helped me a l
View Tutorial          By: Rakesh Verma at 2008-06-25 13:25:23