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! Ramlak It Working But Sms didnot send why? and
View Tutorial          By: balaji at 2008-01-28 02:41:47

2. wow... and Thanks...
View Tutorial          By: lasitha at 2010-07-24 21:38:50

3. HI,
I want to send an sms via website to mo

View Tutorial          By: Hemant at 2008-11-04 05:26:30

4. programs are making the concept easy.its a nice pr
View Tutorial          By: veeru at 2010-05-12 22:10:25

5. Where should I put the xml file ??????????
View Tutorial          By: Marya at 2014-03-21 16:01:13

6. basic example on serialization... its good and cle
View Tutorial          By: Rag at 2012-01-08 02:53:41

7. Thank you so much
View Tutorial          By: Daniel at 2011-02-14 22:47:05

8. u doing good
View Tutorial          By: matsiko at 2009-04-14 08:05:00

9. this is really helpful example for Learning RMS in
View Tutorial          By: Ahmed Nawaz Mari at 2011-06-30 05:29:18

10. can u give video of this code how it work & w
View Tutorial          By: vishal mande at 2015-04-04 08:20:30