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 project, and need help please. I ne
View Tutorial          By: kelvin65 at 2009-05-25 10:03:07

2. i need save,delete,update use arrayList.
th

View Tutorial          By: kyaw at 2010-04-07 01:55:02

3. i got an error msg at runtime of jdbc program with
View Tutorial          By: madhu sudan at 2012-06-17 02:52:53

4. Hi,
how can make a report to display one re

View Tutorial          By: david at 2013-08-30 16:09:23

5. super
View Tutorial          By: Dhana at 2007-01-30 03:21:00

6. i nice programs tks
View Tutorial          By: jai at 2011-05-09 14:09:38

7. Nice Intro .......
View Tutorial          By: MohanRaja at 2012-06-28 11:02:40

8. how to execute all the 5 files plz tell me step by
View Tutorial          By: asraf at 2007-11-14 22:29:20

9. Hello Friends, i am getting an error in following
View Tutorial          By: Albin at 2008-07-10 23:49:33

10. Hi, I need the complete working code for recieving
View Tutorial          By: Issam at 2008-09-26 01:24:04