6.3. Scope of a Declaration
The scope of a declaration of a member m
declared in or inherited by an interface type I (§9.1.4) is the entire body of I, including any nested type declarations.
interface I{
class C{}
static class D{}
}
The scope of a class‘s type parameter (§8.1.2) is the type parameter section of the class declaration, the type parameter section of any superclass or superinterface of the class declaration, and the class body.
The scope of an interface‘s type parameter (§9.1.2) is the type parameter section of the interface declaration, the type parameter section of any superinterface of the interface declaration, and the interface body.
interface IU<T>{ }
class CU<T>{}
public class main3<X extends Number> extends CU<X> implements IU<X> {
}
The scope of a constructor‘s type parameter (§8.8.4) is the entire declaration of the constructor, including the type parameter section, but excluding the constructor modifiers.
public class main3{
public <A,B extends A> main3(){
}
}
The scope of a local variable declaration in a block (§14.4) is the rest of the block in which the declaration appears, starting with its own initializer and including any further declarators to the right in the local variable declaration statement.
int a = 1,b = a;
The scope of a local variable declared in the ForInit part of a basic for
statement (§14.14.1) includes all of the following:
ForInit、ForInitializer与ForUpdate