You cannot have multiple declarations of different types. : for « Statements « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Statements » for 
5.3.6.You cannot have multiple declarations of different types.
public class MainClass {
    public static void main(String[] argv){
       for (int i = 7long j = 0; i < 10; j++) { } // illegal!
    }

}
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
	Syntax error on token "long", delete this token

	at MainClass.main(MainClass.java:3)
5.3.for
5.3.1.The for() Loop
5.3.2.You are allowed to declare variables in the statement part.
5.3.3.Empty for() Loops
5.3.4.The for() Loop and the Comma Separator
5.3.5.You cannot mix expressions with variable declarations
5.3.6.You cannot have multiple declarations of different types.
5.3.7.Using comma to separate multiple declarations of a single type
5.3.8.A loop counter declared in the initialization section has a scope restricted to the loop.
5.3.9.Bare minimum for loop, with "{}" representing an empty code block:
5.3.10.Here are two more practical examples of for loops with missing parts:
5.3.11.skips the initialization section because the variable x is already initialized
5.3.12.You can have only one test expression.
5.3.13.Causes of Early Loop Termination
5.3.14.for loop may act like a while loop.
5.3.15.A for loop with multiple variables
5.3.16.The three expressions in the for statement don't need to operate on the same variables
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.