Hello,
I have wrote this code in esclipse and I am getting error
"Syntax error on token "this", invalid ReferenceType"
on the second line? could some one explaine why?
public boolean equals(Object f){
if( ( f instanceof this ) && ( this instanceof f )){
if( this.size() == f.size()){
int j=1;
while( j<=this.size()){
if( f[i] == null && this[i] == null ) {
if( this[i] != null && this[i] == f[i] ){
j++;
}
}
}// END WHILE
}// END IF 2
return OK;
}// END IF 1
else return NOTOK;
}// @-->---

Signature
Thanx in advance
________________________
Torkel Franzen - 21 Jan 2006 10:43 GMT
> Hello,
>
[quoted text clipped - 4 lines]
> public boolean equals(Object f){
> if( ( f instanceof this ) && ( this instanceof f )){
Your use of instanceof is nonsensical. Check out instanceof in your
favorite text.
Mark Thomas - 21 Jan 2006 16:24 GMT
>>Hello,
>>
[quoted text clipped - 7 lines]
> Your use of instanceof is nonsensical. Check out instanceof in your
> favorite text.
You know what class 'this' is - it's the class your equals() method is
defined in. So if this code is in the Widget class, you could say 'f
instanceof Widget'. If you did want to ensure that 'this' and 'f' were
the same class you could use 'this.getClass() == f.getClass()', but you
really don't need that.
Mark
Roedy Green - 21 Jan 2006 10:52 GMT
>this[i]
this does not make any sense. It would make sense to same something
like
these[i] where these= new TypeOfThis[n];

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
opalpa@gmail.com opalinski from opalpaweb - 21 Jan 2006 16:33 GMT
You got lots of problems with your code man. Your code is
approximately half Java and half something else.
Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/
Stefan Schulz - 22 Jan 2006 20:34 GMT
> public boolean equals(Object f){
> if( ( f instanceof this ) && ( this instanceof f )){
Read up on the "instanceof" operator. Hint: What you want to do is
easily achived using getClass == f.getClass()
> if( f[i] == null && this[i] == null ) {
> if( this[i] != null && this[i] == f[i] ){
this[i]? What do you want to do? This is absolutely guaranteed never to
be of an array type (since these are created on the fly by the JVM)
> }// END WHILE
> }// END IF 2
> return OK;
> }// END IF 1
> else return NOTOK;
> }// @-->---
Why not use true or false?