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. Hi I have a USB bluetooth that plug in my computer
View Tutorial          By: venkat c s at 2008-07-21 12:15:46

2. its amazing for me i learn a lot from it thanks..
View Tutorial          By: sufyan at 2014-10-26 14:39:34

3. crystal clear explanation
View Tutorial          By: digant at 2009-12-08 09:10:06

4. i should say, a lot of thank you because of this s
View Tutorial          By: merven at 2009-03-17 09:45:39

5. great material for language bugs....
View Tutorial          By: manoj kapri at 2009-11-30 00:30:13

6. nice
View Tutorial          By: rida at 2010-07-03 22:49:04

7. Thanks Thanks Thanks.....for you
But how

View Tutorial          By: jihad at 2009-02-15 04:48:53

8. Good tutorial sir
View Tutorial          By: vinay at 2012-01-28 12:38:30

9. hie
can u plz tell how i maintain my rms f

View Tutorial          By: diya at 2010-04-30 01:38:06

10. I want to know the difference between java and .ne
View Tutorial          By: Jack at 2010-06-10 07:40:35