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

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 am running it within NetBeans. I set a breakpoin
View Tutorial          By: PeteC at 2014-02-22 18:57:14

2. Nice example of System.arraycopy()function. Thank
View Tutorial          By: Rahul Raj at 2015-08-17 03:11:44

3. Guys, txtWeb is back with their National Level Dev
View Tutorial          By: rahul.del at 2012-08-16 10:01:09

4. hi..
recipient: 9994852342 message: chadru<

View Tutorial          By: chandrasekaran at 2009-05-04 09:00:47

5. Hy plz help me for also draw to flowchart.........
View Tutorial          By: khadija at 2010-11-13 11:38:31

6. import java.io.*;
import java.util.Stack;
View Tutorial          By: jack&jill at 2011-07-26 06:40:32

7. how does struts work in netbeans 6.9.1?what are th
View Tutorial          By: gunavathi at 2014-05-14 08:00:56

8. Very good. Keep it up.
View Tutorial          By: jk at 2009-05-23 11:00:29

9. sir every time we are using this.wedth(for example
View Tutorial          By: praveen kumar at 2011-06-28 01:33:44

10. hi this is from iniyan....
can you send t

View Tutorial          By: iniyan at 2007-09-09 06:50:18