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 sir
im a student of aitm im doing speec

View Tutorial          By: sinan ahmed at 2015-02-09 05:45:49

2. I liked it.
View Tutorial          By: savitha at 2011-05-06 02:23:46

3. if the number is for exemple 00025478 it return a
View Tutorial          By: ahmed at 2015-02-11 12:02:45

4. i can't understand the deadlock clearly
View Tutorial          By: kalpana at 2012-11-01 11:26:09

5. This is the best example for beginners. After read
View Tutorial          By: BB at 2014-05-20 05:24:09

6. really understandable
but 'm expecting with

View Tutorial          By: rajkumar at 2008-03-14 03:53:21

7. need to be place taglig in the <jsp-config>
View Tutorial          By: Shaik Basha at 2013-01-30 03:11:41

8. Good example but hard to read. Every other word is
View Tutorial          By: Eugene at 2012-03-28 12:19:44

9. Thank you so much. You made my day. God bless you
View Tutorial          By: Gautam at 2012-09-18 16:24:19

10. I want to store the Data in Vector or the LinkedLi
View Tutorial          By: Sobia at 2013-01-17 11:24:59