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



Related Tutorials

Java program to get location meta data from an image

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

Archived Comments

1. Your site is a really big help. Straight to point
View Tutorial          By: Mark Anthony Santos at 2008-12-16 22:03:57

2. hi iam new to java i need simple java programs pls
View Tutorial          By: naga at 2010-10-06 03:45:18

3. I am very much thankfull to you in providing the c
View Tutorial          By: c vijaychandar at 2010-05-05 10:14:59

4. A very good demonstration o Vector!!
View Tutorial          By: Pankaj Kumar Mishra at 2010-12-09 01:35:06

5. Hi its good for the learners and thosse who forgot
View Tutorial          By: Md.Abdul Gaffar at 2008-01-12 06:00:14

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

7. why 27's example is prone to a deadlock ? when pro
View Tutorial          By: kaka at 2011-08-14 00:59:41

8. werst program out put nt comming
View Tutorial          By: anu at 2012-08-02 13:09:00

9. Thanks for the solution. I must say however that t
View Tutorial          By: Pierre at 2009-11-19 20:16:35

10. thanks for posting
View Tutorial          By: sriram at 2011-11-24 06:38:42