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



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. easy to understand
View Tutorial          By: shanthi at 2011-01-02 21:25:51

2. Thanks a lot !
View Tutorial          By: Kalander bava ta at 2012-11-04 08:07:15

3. Could you please explain how to define our own val
View Tutorial          By: xxxxx at 2010-06-30 06:41:14

4. Thank you very much for explaning the things in su
View Tutorial          By: Sunil Yadav at 2010-05-27 04:04:31

5. ' REFERENCIA EN EL PROYECTO (Microsoft Excel 12.0
View Tutorial          By: Anonymous at 2015-04-21 03:10:41

6. Good tutorial.
View Tutorial          By: Pinky at 2010-03-11 10:42:49

7. Please send me working code and setup,,My mail id
View Tutorial          By: Karthik at 2012-03-30 19:56:35

8. your code helps a lot.....
thanx......

View Tutorial          By: beh at 2009-08-19 06:06:20

9. thanks for this sample.. it possible to handle the
View Tutorial          By: nel at 2011-06-13 22:59:45

10. thnkss buddyy its very helpful for my assignmentss
View Tutorial          By: yamini at 2011-02-25 21:01:23