AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Syntax error on token "this", invalid ReferenceType

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Carramba
Guest





PostPosted: Sat Jan 21, 2006 10:42 am    Post subject: Syntax error on token "this", invalid ReferenceType Reply with quote




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;
}// @-->---
--


Thanx in advance
________________________



Back to top
Torkel Franzen
Guest





PostPosted: Sat Jan 21, 2006 10:43 am    Post subject: Re: Syntax error on token "this", invalid ReferenceType Reply with quote



Carramba <nospam (AT) note (DOT) com> writes:

Quote:
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 )){

Your use of instanceof is nonsensical. Check out instanceof in your
favorite text.

Back to top
Roedy Green
Guest





PostPosted: Sat Jan 21, 2006 10:52 am    Post subject: Re: Syntax error on token "this", invalid ReferenceType Reply with quote



On Sat, 21 Jan 2006 11:42:09 +0100, Carramba <nospam (AT) note (DOT) com> wrote,
quoted or indirectly quoted someone who said :

Quote:
this[i]

this does not make any sense. It would make sense to same something
like

these[i] where these= new TypeOfThis[n];

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Back to top
Mark Thomas
Guest





PostPosted: Sat Jan 21, 2006 4:24 pm    Post subject: Re: Syntax error on token "this", invalid ReferenceType Reply with quote

Torkel Franzen wrote:
Quote:
Carramba <nospam (AT) note (DOT) com> writes:


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 )){


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

Back to top
opalpa@gmail.com opalinsk
Guest





PostPosted: Sat Jan 21, 2006 4:33 pm    Post subject: Re: Syntax error on token "this", invalid ReferenceType Reply with quote

You got lots of problems with your code man. Your code is
approximately half Java and half something else.

Opalinski
[email]opalpa (AT) gmail (DOT) com[/email]
http://www.geocities.com/opalpaweb/

Back to top
Stefan Schulz
Guest





PostPosted: Sun Jan 22, 2006 8:34 pm    Post subject: Re: Syntax error on token "this", invalid ReferenceType Reply with quote


Quote:
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()

Quote:
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)

Quote:
}// END WHILE
}// END IF 2
return OK;
}// END IF 1
else return NOTOK;
}// @-->---

Why not use true or false?


Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.