Listing 2 shows a typical static initializer.
清单2显示了典型的静态初始化器。
Provide a GBeanInfo static initializer that describes the constructor.
提供描述构造函数的gbeaninfo静态初始化器。
In a static initializer block, which executes when the class is loaded.
在一个静态初始化块中,在加载类时执行。
The static initializer runs first, as the class is loaded, followed by the main method (which is also static).
加载类之后,静态初始化器首先运行,紧接着运行的是main方法(也是静态的)。
Before we can use ofy, however, we need to register persistent classes in a static initializer like Photo in Listing 2.
然而,在我们使用ofy之前,我们需要在一个静态的初始化方法中注册持久化类,如清单2的Photo。
The static initializer in Listing 2 shows the registration process for a Customer class that contains two properties: name and salary.
清单2中的静态初始化器显示了Customer类的注册过程,这个类包含两个属性:name和salary。
A permissions class with a static initializer provides a single location for declaring and configuring available application permissions.
带有静态初始化器的permissions类为声明和配置可用的应用程序权限提供单一位置。
This information resides in a BeanInfo class, which is typically provided by your bean when the bean's class is loaded via a static initializer.
这条信息位于beaninfo类中,该类通常在bean的类通过静态初始化器装入时,由bean提供。
Permissions is never instantiated — it features a static initializer that builds up the enum types that configure permissions for the application.
Permissions从不实例化,它提供构建Enum类型的静态初始化器,该Enum类型可以为应用程序配置权限。
The second scenario is when a type has a initializer for a static field, in which case the compiler adds a type constructor behind the scenes.
第二种情况是,类型具有一个用于静态字段的初始值设定项,在这种情况下,编译器会在后台添加类型构造函数。
As you saw earlier, the code for a static field initializer executes inside an implicit type constructor.
正如您在前面看到的那样,静态字段初始值设定项的代码在隐式类型构造函数的内部执行。
The same rules hold true if the exception is thrown from a static field initializer.
如果异常是从静态字段初始值设定项引发的,也存在同样的规则。
Metadata about operations, references, and basic attributes are initialized in a static block initializer, as shown in Listing 3.
有关操作、引用以及基本属性的元数据在一个静态初始程序块中被初始化,如清单3所示。
You should utilize the initializer syntax for both static and instance variables.
你应该在静态变量和实例变量上面利用初始化语法。
As with instance initialization, you can use the initializer syntax as an alternative to the static constructor.
和实例初始化一样,可以使用初始化器语法作为静态构造函数的变体。
External and static variables are initialized to zero by default. Automatic variables for which is no explicit initializer have undefined (i. e., garbage) values.
外部变量和静态变量初始的时候默认值为零,自动变量在初始的时候是没有默认值的。
If you simply need to allocate a static member, use the initializer syntax.
如果你需要简单的分配一个静态成员,那么可以使用初始化器语法。
If you simply need to allocate a static member, use the initializer syntax.
如果你需要简单的分配一个静态成员,那么可以使用初始化器语法。
应用推荐