Yes, it is possible to instantiate two variables of the same type in the for loop declaration.
But this example is an infinite loop, because you test the variable that isn't incremented.
Just try it out at the code playground.
Declaring multiple variables in a single declaration could cause confusion about the types of variables and their initial values. In particular, do not declare any of the following in a single declaration:
- Variables of different types
- A mixture of initialized and uninitialized variables
In general, you should declare each variable on its own line with an explanatory comment regarding its role. While not required for conformance with this guideline, this practice is also recommended in the Code Conventions for the Java Programming Language, §6.1, “Number Per Line” [Conventions 2009].