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. through this i understand functional overloading e
View Tutorial          By: mahwash at 2012-09-19 15:29:21

2. thanx for providing good knowledge @ overriding
View Tutorial          By: Amol at 2011-05-05 02:28:43

3. supb yar...very helpful
View Tutorial          By: narender lakshetty at 2010-07-23 23:20:00

4. Sir, this is very helpful for students and profess
View Tutorial          By: Pankaj Choudhary at 2010-10-19 00:24:36

5. java use real world object ............
View Tutorial          By: yunus khan at 2012-12-07 08:24:47

6. This is just the web service, if you want to consu
View Tutorial          By: Carlos Kassab at 2015-02-20 17:18:06

7. thank for this
View Tutorial          By: ankit at 2011-07-15 06:48:21

8. Hi,i'm added the certificate to java keystore,But
View Tutorial          By: chakri at 2014-09-18 07:22:41

9. thank you man.
View Tutorial          By: Hariharan at 2012-08-03 01:39:16

10. Nice code easily understand the code and useful
View Tutorial          By: satish at 2010-01-22 06:30:22