Hi Chunky,
Let me explain the reason of the problem.
In the first case,
the expression within the <code>
while </code> is evaluated to false so the statement <code>
int k = 2; </code> is not executed but as per
JLS 14.11 . The <code>
while </code> must have a block or and executable statement.
You can verify it by refering to the code below :
Having said that, in the second case the <code>
while </code> loop does has ending block in the form of <code>
{ } </code> . So the compiler doesnt complains. Please note that the statement inside the while loop is not executive in both
cases.
Manfred
the code of chunky has nothing to with multiple declaration of the variable 'k'. That line just aint getting executed as the condition in while evaluates to falsity.
Hope this clarifies the issues.
Rgds,
Ravindra Mohan.
[This message has been edited by Ravindra Mohan (edited May 04, 2001).]