Comment on Tutorial - compareTo( ) in Java By Mashoud



Comment Added by : Abhishek

Comment Added at : 2011-04-09 23:31:28

Comment on Tutorial : compareTo( ) in Java By Mashoud
I am trying to figure out what our Professor did when he was doing this code. I can see he is type casting, but I cant understand the line 2 where he is having a ".a" after typecasting "0".
Can anyone please help me understand this code better?

1. public int CompareTo ( Object o )
2. if( this.a < (( Test)o).a )
3. return -1;
4. else if (this.a == (( Test )o).a)
5. return 0;
6. else
7. return 1;


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. pls help me how to solve the timeout problem

View Tutorial          By: nisha at 2010-09-20 22:29:17

2. Respected Sir,
We are

View Tutorial          By: Core Java at 2009-10-24 01:36:20

3. What is the \ in several of the string building st
View Tutorial          By: rogerb at 2012-01-28 23:07:31

4. Hi all this program is working very fine .... i ha
View Tutorial          By: Ashish at 2009-03-25 04:28:25

5. Thanks a lot for this great post.
View Tutorial          By: Ram Para at 2012-03-23 17:07:09

6. I have to ask; Where do we put the text boxes?
View Tutorial          By: Jeremy at 2010-10-07 14:37:07

7. The example shown and ur way of explaining is good
View Tutorial          By: Devi at 2009-02-24 07:19:26

8. Just what I was looking for. Great work. thx.
View Tutorial          By: SP Goh at 2008-03-24 01:09:09

9. I am getting the following exception
Error

View Tutorial          By: Balraj Selvakumar at 2008-10-14 03:12:20

10. Just what I was looking for. Thank you.
View Tutorial          By: Babool at 2008-05-08 08:32:50