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. @Jai Shankar K

I'm guessing you are

View Tutorial          By: Nick Scroggs at 2013-03-26 01:44:04

2. Did you check if you are using the correct usernam
View Tutorial          By: Murugan at 2011-11-18 09:28:47

3. Thank you for sharing your knowledge. =>
View Tutorial          By: Condel Batac at 2013-02-03 23:17:26

4. Very useful n understandable. More understandable
View Tutorial          By: Kiran at 2015-08-27 06:13:00

5. I need the multiple record store RMS code.Pls help
View Tutorial          By: Raghuvir at 2009-05-13 23:03:44

6. really very excellent example....ThanQ...:)
View Tutorial          By: Tulasi at 2010-08-17 00:41:21

7. I think the programmer overlooked that "this
View Tutorial          By: Joe Schmoe at 2010-10-16 00:01:27

8. nice cursor beside learn java...but i do not know
View Tutorial          By: yazidie_y at 2008-03-08 03:33:03

9. i found this very pleasing for both my brain and m
View Tutorial          By: Matthew Redisons at 2012-10-03 14:36:32

10. how run struts in eclipse can explain with an exam
View Tutorial          By: Grace at 2015-08-14 02:41:28