Static fields and methods are supposed to represent stateless attributes of a class;
静态域和方法都应该代表一类无国籍属性;
This is unusual because it requires a developer to create an instance of an object just to access non-instance (static) methods and fields!
这种做法并不常见,因为需要开发人员创建仅用于访问非实例(静态)方法和字段的对象的实例。
Support for importing constants: This facility allows static methods and fields to be imported, avoiding the need to use fully qualified class names when accessing static members.
支持导入常量:这个特性使静态方法和字段能够被导入,这样在访问静态成员时就不必使用完全限定的类名。
It would be much better to simply prevent the programmer from referring to generic types in static fields, as is done in the case of static methods and classes.
象对静态方法和类所做的那样,只要防止程序员在静态字段中引用泛型类型,情况就会好很多。
Rather, static crosscutting allows you to alter the structure of an object by introducing additional methods, fields, and properties.
相反,它允许通过引入附加的方法字段和属性来修改对象的结构。
Without beforefieldinit, the runtime must run the type constructor at a precise time-just before the first access to static or instance fields and methods of the type.
如果没有beforefieldinit,运行库就必须在某个精确时间运行类型构造函数,即,恰好在第一次访问该类型的静态或实例字段和方法之前。
If you wanted to change the code so that you could change the ResourceBundle dynamically, you would need to change the Messages class so that its fields and methods weren't static.
如果您想更改代码,以便动态地改变ResourceBundle,那么需要修改messages类,使它的字段和方法不是静态的。
You can also call static methods on classes and access classes' static fields. Observe!
也可以调用类的静态方法或访问类的静态字段。
You can also call static methods on classes and access classes' static fields. Observe!
也可以调用类的静态方法或访问类的静态字段。
应用推荐