mightyandweakcoder :
int v=0;
for(v;v<2;v++){
...
}
Why is this not allowed in Java? Why do we have to declare variable v in the for loop initialization ? I know it's not a statement if i do it like that but why doesn't Java allow the above?
Eran :
If v
is declared prior to the loop, you should leave the first part of the for statement empty:
int v=0;
for(; v < 2; v++){
...
}
There's no meaning to just writing v;
.