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 .....its hard to understand for me th
View Tutorial          By: heidi at 2010-06-27 02:31:29

2. if i wanna push the data from my keyboard input, h
View Tutorial          By: andys at 2008-11-09 03:09:32

3. Ku is quite correct. When you create any object, i
View Tutorial          By: Avnish at 2010-10-28 04:00:20

4. any help please I'm getting this exception

View Tutorial          By: Bull at 2012-01-02 17:22:18

5. Error loading SolarisSerial: java.lang.Unsatisfied
View Tutorial          By: Rahul at 2008-09-09 04:05:35

6. Exception in thread "Thread-0" java.lang
View Tutorial          By: yash at 2009-09-16 06:12:32

7. very good....
View Tutorial          By: satish at 2010-03-03 22:47:25

8. I find dis site very educating
View Tutorial          By: Kensho at 2009-05-09 05:18:57

9. Verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
View Tutorial          By: Amarnath.A at 2011-07-14 00:32:08

10. i want the database connectivity for telephone bil
View Tutorial          By: rohan at 2015-04-05 05:01:46