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. i want full information of java topics
View Tutorial          By: mahesh at 2008-12-14 23:38:50

2. it good to understand struts arch.
View Tutorial          By: i know about hibernate all type of query? at 2012-07-30 07:08:39

3. i can understand easily what is isset but i am not
View Tutorial          By: sebestiraj at 2010-04-09 00:09:36

4. Timely info right when I needed it. Thanks.
View Tutorial          By: Electric Vehicles at 2008-12-10 15:15:25

5. we can create reference variable for an abstract c
View Tutorial          By: siva at 2012-08-30 06:03:50

6. hey it is really good notes, to give an idea of
View Tutorial          By: Pawan at 2011-03-26 05:17:28

7. Thank you, I need exactly this; cheers :)
View Tutorial          By: Lang at 2011-04-08 09:33:24

8. hi friends,
can i write the same jdbc code

View Tutorial          By: mahesh at 2012-01-05 05:09:38

9. What is a mean by maintaining the Session State of
View Tutorial          By: Saranya at 2011-05-14 13:17:42

10. i am looking for the code which wiLL HAVE AFFECT I
View Tutorial          By: pooja at 2013-06-10 13:48:32