File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in calling setter method

 
Achint Verma
Greenhorn
Posts: 12
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get these errors on Eclipse upon calling the setter method setSize().
Is there anything wrong in line 4 ?

Multiple markers at this line
- Syntax error on token(s), misplaced
construct(s)
- Syntax error on token "34", delete this
token


for the code



Can anyone explain why am I getting these errors ?
 
Raghu Devatha
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The line b.setSize(34); should be in a method of Class A because the method setSize does not return anything.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47250
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right answer, wrong explanation; the reason is that statements cannot be put loose in the class. You ought to put those statements into a method. It is only the 3rd line the compiler will complain about because the 1st and 2nd lines are declarations, which are permitted loose in the class
 
Winston Gutkowski
Bartender
Pie
Posts: 9472
50
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch Achint.

Winston
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic