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 can't get getword function.Where is that written
View Tutorial          By: withu at 2010-01-26 23:25:12

2. Thanks a lot!
The main reason why we need t

View Tutorial          By: SA at 2011-06-24 15:00:13

3. public class Overload2 {


View Tutorial          By: ITMIT at 2011-06-05 19:16:46

4. you have extended class Abc within class Abc

View Tutorial          By: SUNIL SHAH at 2012-05-25 06:17:23

5. i like java language.
View Tutorial          By: deepika at 2014-09-22 15:11:39

6. hi everbody. i need to extract a output from one j
View Tutorial          By: keerthi at 2010-10-29 13:38:28

7. i totally disagree with Gerardo Saldív
View Tutorial          By: Shivesh at 2009-09-24 23:46:42

8. this work is good
View Tutorial          By: sanath at 2008-12-15 01:18:43

9. Dear Samantha, Thx for pointing the extra \. I hav
View Tutorial          By: Emiley at 2011-06-06 04:50:40

10. hey Mounika..did u solve ur problem ??if u did ple
View Tutorial          By: agnas at 2008-04-28 23:59:37