I am trying to initialize different types in initialization expression of simple FOR loop but there is an error - Type mismatch: cannot convert from BigInteger to int; Syntax error on token "bigInt2", delete this token.
I trying for BigInteger but even if I do for primitives then also I get error.
Below is what I am trying.
for (int j = 1, BigInteger bigInt2 = new BigInteger("1");
j < 1000000; j++, bigInt2 = bigInt2.add(bigIntBase)) {
Questions:
- Am I doing something wrong or it is not allowed?
- If not allowed then why? I know using different types in the increment expression is allowed.
Work around I know:
I know work around that I can initialize before the FOR loop but it breaks the whole purpose of initialization expression because if that to happen then whole initialization expression could have been removed from FOR loop and developer could have done it before FOR loop.