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. i connect my program to my sql and create table. a
View Tutorial          By: Santosh Agrawal at 2013-04-08 13:00:56

2. this helped a lot!!!!
View Tutorial          By: karthik rk at 2012-09-04 16:32:25

3. Can you help me input 15 states and capitals in 2
View Tutorial          By: Hardik Negandhi at 2015-06-24 11:18:51

4. hello sir,
i am create project autosubtitle

View Tutorial          By: Dilip Gauswami at 2013-12-01 06:46:34

5. HI can you send "send sms" program throg
View Tutorial          By: manav at 2010-05-09 12:54:52

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

7. hi.. how can i extrate day, month, year from date
View Tutorial          By: avkash at 2010-10-03 05:19:58

8. M finding difficulty in understanding Java. Can an
View Tutorial          By: Sunil at 2010-09-28 03:54:57

9. SMSC number is the sms center no. put the sim to a
View Tutorial          By: Java MAn at 2012-01-28 19:08:23

10. S.N. Constructor & Description
1 String

View Tutorial          By: Jameesh at 2015-03-05 07:09:38