why do we not have multiple initialization in for loop? we do have multiple increment statements.
code:
for(int i=1,int c=4;i<1;i++)
System.out.println(c);
This code shows a compile time error.
why do we not have multiple initialization in for loop? we do have multiple increment statements.
code:
for(int i=1,int c=4;i<1;i++)
System.out.println(c);
This code shows a compile time error.
You are using wrong syntax. You can use this way
for(int i=1, c=4;i<1;i++)
If by "have multiple increment statements" you mean e.g.
for(int i=1, c=4;i<1;i++,c++)
// ^ ^
// | |
// Multiple increment expressions
First of all, they are expressions and not statements. Secondly, i++,c++
is one expression, using the comma operator to separate two sub-expressions.