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. You saved my but by posting this. Thank You. I j
View Tutorial          By: cranakis at 2014-09-19 16:10:20

2. i need help in writing code for multiplication pro
View Tutorial          By: viswanath at 2013-02-23 14:13:40

3. i want to know java coding
View Tutorial          By: carmela azarce at 2012-08-08 02:47:13

4. i wrote ocjp exam on oct 27,2012. But still i didn
View Tutorial          By: Yashwinkkumar R at 2013-02-17 09:05:29

5. It was really helpful.... i cleared my lab test wi
View Tutorial          By: kishore at 2009-01-21 22:30:08

6. can anybody tell me the full code for sending sms
View Tutorial          By: shikha at 2008-10-13 11:43:40

7. Yes, finaly toString start making sense to me, tha
View Tutorial          By: Ted at 2010-04-10 19:15:50

8. Very helpful.
View Tutorial          By: Krishna at 2012-06-14 10:25:00

9. pls help on me to program in c++, write a program
View Tutorial          By: Hamid at 2014-12-18 20:41:40

10. My question is, from where the name "java&quo
View Tutorial          By: Sreedevi at 2013-05-18 10:41:38