清单2显示了典型的静态初始化器。
对初始化器列表使用auto。
清单12说明如何访问初始化器列表。
这个列表是使用定义的,它是初始化器列表。
可以在变量定义中使用初始化器列表。
由于采用这种语义,应该尽可能使用初始化器列表。
Given this kind of semantics, using initializer lists should be preferred whenever possible.
实例初始化器允许您为一个匿名内部类执行构造代码。
Instance initializers allow you to execute construction code for an anonymous inner class.
可以在new表达式中使用初始化器列表。
对象初始化器,简化了对象的构造和初始化。
Object initializers, which ease construction and initialization of objects.
在初始化阶段,类中包含的静态初始化器都被执行。
During the initializing phase, any static initializers contained within a class are executed.
对象初始化器指定一个或多个对象的域或属性的值。
An object initializer specifies values for one or more fields or properties of an object.
如果使用静态初始化器,就不可能自己捕获异常了。
If you use static initializers, you cannot catch the exceptions yourself.
元类将创建此类(作为一个新式类)并将其传递给类初始化器过程。
The metaclass will create the class (as a new style one) and will pass it to the class initializer procedure.
提供描述构造函数的gbeaninfo静态初始化器。
Provide a GBeanInfo static initializer that describes the constructor.
初始化器列表和类型窄化(type narrowing)
如果用空的初始化器列表对变量进行初始化,对象为初始化值。
If a variable is initialized with an empty initializer list, the object is value initialized.
每当需要一个特殊类型时,该类型的初始化器就很明显地被提升成类型本身。
Whenever a particular type is required, the initializer for that type is transparently lifted into the type itself.
在等号后指定集合初始化器的成员初始化器是对内嵌集合的初始化。
A member initializer that specifies a collection initializer after the equals sign is an initialization of an embedded collection.
在研究初始化器列表示例和典型用法之前,先讨论一下什么是类型窄化。
Before moving on to initializer list examples and typical usage, let's look at what is meant by type narrowing.
和实例初始化一样,可以使用初始化器语法作为静态构造函数的变体。
As with instance initialization, you can use the initializer syntax as an alternative to the static constructor.
新的auto语法:根据初始化器(initializer)表达式推导类型。
Welcome to the new auto syntax: type deduction from initializer expressions.
本书中我们使用数据库初始化器在每次模型变化时来删除和重建数据库。
Throughout this book we have used database initializers to drop and recreate the database every time the model changes.
由于默认初始化器的存在,如果需要执行下列代码,你不需要做任何设置。
Because this is the default initializer, you shouldn't need to set it, but if you find a need to you can use the following code.
就php来说,这个对象初始化器的参数是path、host和port。
In the case of PHP, the arguments to this object initializer are path, host and port.
加载类之后,静态初始化器首先运行,紧接着运行的是main方法(也是静态的)。
The static initializer runs first, as the class is loaded, followed by the main method (which is also static).
对象初始化器中的赋值作为域或属性成员的赋值对待,而不是给域或属性赋予新值。
Instead of assigning a new value to the field or property, the assignments in the object initializer are treated as assignments to members of the field or property.
我们将在类的静态初始化器中把 EmbeddedDriver 用于驱动程序类。
We use the EmbeddedDriver for our driver class in the static initializer of the class.
我们将在类的静态初始化器中把 EmbeddedDriver 用于驱动程序类。
We use the EmbeddedDriver for our driver class in the static initializer of the class.
应用推荐