SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Originally posted by marc weber:
//why does the compiler says "identifier expected" when
//we say size++; instead of the above code line ???
//A statment like System.out.println(size++); also doesn't
//work if written in plae of above code line
Because this is not within a method. You can declare (and initialize) a variable here (or any other class member), but you can't perform an "action" (like incrementing a variable or calling a method).
//Why do we get error here even if we have declared
//the variable 'i' to be static ???
Because size is not declared static in Fish, so you're trying to access a non-static variable (size) from a static context (main).
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Originally posted by Rob Spoor:
I think you CAN perform actions in static declaration with immediate initialization.
Originally posted by Rob Spoor:
The problem is, because of the previous error, i is not correctly been added to the list of known variables and therefore is not recognized.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Originally posted by marc weber:
Yes, this is definitely part of the problem. But I was assuming that the above error would be corrected, in which case there's still a "non-static variable from static context" issue.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org