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



Ask a Question

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. can you gave us a sample form that has a design
View Tutorial          By: niknik at 2011-07-01 09:39:21

2. I tried ....so this is best solution for understa
View Tutorial          By: rehnuma at 2015-03-30 12:29:38

3. thanks,Gud job
View Tutorial          By: junaid sheikh at 2012-11-21 16:24:27

4. my question is the same of sajjad.what about (!iss
View Tutorial          By: hossain at 2012-04-26 04:28:56

5. Tnx. Very fast learning i think.
Just make

View Tutorial          By: mahdi at 2011-07-09 20:20:39

6. main is not needed for a simple program...

View Tutorial          By: manoj at 2012-05-29 17:46:08

7. From the last 2 year. i'm working on hibernate fra
View Tutorial          By: nick at 2011-01-03 02:11:48

8. Before i had lot of doubts in abstract class... no
View Tutorial          By: Mohandoss at 2012-04-02 05:08:43

9. I need how to connect with database connection in
View Tutorial          By: BenGunn at 2010-01-12 03:33:44

10. Detect OS of iphone using Java Code
View Tutorial          By: Naina at 2012-07-31 11:07:09