Each class declaration has an associated bound type (§4.4.3), the instance type. For a generic class declaration, the instance type is formed by creating a constructed type (§4.4) from the type declaration, with each of the supplied type arguments being the corresponding type parameter. Since the instance type uses the type parameters, it can only be used where the type parameters are in scope; that is, inside the class declaration. The instance type is the type of this for code written inside the class declaration. For non-generic classes, the instance type is simply the declared class. The following shows several class declarations along with their instance types:
class A // instance type: A
{
class B {} // instance type: A.B
class C {} // instance type: A.C
}
class D {} // instance type: D
Do'stlaringiz bilan baham: |