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
- Syntax error on token "34", delete this
for the code
Can anyone explain why am I getting these errors ?
Joined: Feb 10, 2009
The line b.setSize(34); should be in a method of Class A because the method setSize does not return anything.
Joined: Oct 13, 2005
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