I have not seen the exact question here that surprises me.
The following commands will not compile:
public int compareTo( Object o ) { if ( this.order < ((Category o).order) ) { return -1; } else if ( this.order > ((Category o).order) ) { return 1; } else { return 0; } }
While changing this in order to drop the object and keep its reference in the new object outside the conditional statement, the problem is fixed:
Category cat = ( Category )o; if ( this.order < cat.order )
My question is: why is this behavior prohibited in Java? (Java 5 specifically)
EDIT: Yeah! Thank you all. Trim modern IDEs giving vague error messages. I began to throw them off, which this time did not help me. (Netbeans warned me about all the missing brackets and there was no semicolon ...)
source share