JLS 12.4.1 理解困难

JLS 12.4.1 difficulty in understanding

在JLS中是这样写的:A class 或者接口类型T .

我的问题是上面的like是什么意思? 这是否意味着:接口 a < T >

任何人都可以用例子解释下面的行吗?

A class or interface type T will be initialized immediately before the first occurrence of any one of the following:

  • T is a class and an instance of T is created.
  • T is a class and a static method declared by T is invoked.

提前致谢

更多详情: 根据此处给出的第 12.4.1 节:http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html

A class 或接口类型 T 将在第一次出现以下任一情况之前立即初始化:

T 是一个 class 并且创建了 T 的一个实例。

T 是一个 class 并且调用了 T 声明的静态方法。

分配了 T 声明的静态字段。

A class or interface type T

就是说T是"some class or interface"。就像数学中的 x 用来表示 "some number".

T is a class and an instance of T is created.

假设您有 class、FooFoo 将在 new Foo() 之前立即初始化,如果尚未初始化的话。

T is a class and a static method declared by T is invoked.

Foo 有一个静态方法 barFoo 将在 Foo.bar() 之前立即初始化,如果尚未初始化的话。


示例 Foo class:

class Foo {
  static void bar() {}
}

A class or interface type T

这意味着: 在下文中,任何时候我们说 T,我们指的是 classinterface