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 am new to java plz give any sample and simple ja
View Tutorial          By: sham at 2012-03-20 02:30:20

2. "paint() sample program to draw a line in J2M
View Tutorial          By: Carlos Alberto Urrea at 2015-02-06 14:00:14

3. Support for serial ports is platform dependent and
View Tutorial          By: Sal at 2009-09-15 15:51:55

4. Plz send me steps to configure and run project to
View Tutorial          By: sandeep kale at 2009-04-08 07:23:45

5. hi i want to run a c program in java program but i
View Tutorial          By: jyothi at 2014-11-27 06:40:27

6. thanks for this tutorial
View Tutorial          By: d3ptzz at 2009-08-03 23:38:57

7. very nice for javascript beginers..
View Tutorial          By: Nilesh at 2012-08-29 10:19:13

8. good example need some more explanation on notify
View Tutorial          By: prashant at 2009-09-08 19:29:54

9. Dear All...................,
I have run the

View Tutorial          By: Ashraf Abu Aisheh at 2008-12-01 13:52:42

10. i want to download a file after the URL connection
View Tutorial          By: mohit at 2011-11-09 11:16:07