File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why is the compiler generates an error message of this type?

 
Varuna Seneviratna
Ranch Hand
Posts: 169
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In the above code the instanceof operator is spelled incorrectly as instanceOf, by making the "O" of "of" capital.In this situation why is the compiler outputs an error message advising to include a parenthesis at the left hand side of obj1 and other error messages
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiler error recovery is a very tricky topic. I think the only way you can really get a feel for the issues involved is by writing some compiler yourself. Basically, while it's easy to write a program that recognizes correct source code, it's exceedingly difficult to write one that recognizes the true intent of invalid source.
 
Sivakumar Janardhanan
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Varuna, i think instanceOf is not a java keyword. that why the compiler gives an error message. now you use this java keyword "instanceof" instead of "instanceOf". it will execute properly.

ok bye
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my guess is that it thinks you are trying to cast a reference you are declaring. In other words, it thinks you are declaring a reference you name 'Parent' of the type 'instanceOf', and are trying to cast it to a reference of type 'obj1'.

(obj1) instanceOf Parent;
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sivakumar janardhanan:
Hi Varuna, i think instanceOf is not a java keyword. that why the compiler gives an error message. now you use this java keyword "instanceof" instead of "instanceOf". it will execute properly.

ok bye

I think we have a winner!
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The original poster knew about the O/o problem; he mentioned it in his first post. I thought the question was not "why do we get an error?" but "why does this error produce this message?"
 
Ken Liao
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rob Prime:

I think we have a winner!


I agree.^_^
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"kendarkfire" please read the important administrative private message which I have just sent you.

CR
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic