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. Good example to know the concept better.
View Tutorial          By: ARAVIND L at 2009-01-05 04:07:46

2. Hi Ramlak,
Am getting
Sat Jan 17 13

View Tutorial          By: Shiv Kumar at 2009-01-17 02:01:01

3. /*Overridding & equals:--> Overriding is an
View Tutorial          By: Naveen Kumar at 2011-04-30 18:44:55

4. Hii.... We are B.Tech 4th year students. We are wo
View Tutorial          By: Shipra Malik at 2010-08-17 03:32:34

5. Can any one help me writing the code...
In

View Tutorial          By: Prajwal at 2011-11-08 10:19:58

6. Travis could you share steps to configure correctl
View Tutorial          By: Shailesh S. at 2015-09-09 09:36:20

7. thanks ........... its so easy and interesting to
View Tutorial          By: sammy at 2011-07-25 00:47:44

8. Thanks, cleared the situation!!
View Tutorial          By: alex at 2010-03-23 16:16:49

9. Very clearly explained...
View Tutorial          By: Bina at 2010-04-08 06:56:37

10. steps 2 create and use tiles
View Tutorial          By: sasank at 2008-10-03 08:06:43