这在好些情况下很容易发生,比如在方法被覆盖而超类使用常规参数声明方法时,还有正在进行许多序列化的系统中也容易发生。
This can happen easily in cases in which methods are being overridden and the superclass declares the method with generic parameters, or in a system where lots of serialization is going on.
将字段声明为受保护时,子类中的方法就有可能直接访问它们,这样就可能有效地增加类层次结构中的耦合。
When fields are declared protected, there is the possibility that methods in subclasses will directly access them, effectively increasing the coupling within a class hierarchy.
继承抽象类的子类必须实现在其父类或自身中声明为抽象的所有抽象方法。
A child class that extends an abstract class must implement all abstract methods in its parent or itself be declared abstract.
简单地说,方法是在类中声明的函数。
必须注意要确保在EJB远程实现类中实际实现了远程接口中声明的方法。
Care must be taken to ensure that methods declared in the remote interface are actually implemented in the EJB remote implementation class.
清单1只包含A SN . 1类中不同方法的声明。
Listing 1 only contains the declarations of the different methods of the ASN.1 class.
将一些方法声明为Private是一个很好的做法,以便保持代码和逻辑位于类中,同时不允许用户直接调用方法。
Declaring some methods Private is a good way to keep code and logic inside a class while not allowing it to be called directly by a user.
class - name是类的完全限定名,方法在此类(或其子类)中声明。
Class-name is the fully qualified name of the class in which the method is declared (or a subclass thereof).
使用引入(Introduction),Aspect可以向类中添加新的方法和变量、声明一个类实现一个接口或将检查异常转换为未检查异常(unchecked exception)。
Using introduction, aspects can add new methods and variables to a class, declare that a class implements an interface, or convert checked to unchecked exceptions.
实现层次结构在Scala中的效果是相同的:我们可以向方法应用final来防止子类覆盖它,也可应用于类声明本身来防止继承。
Implementation hierarchy works the same way in Scala: We can apply final to the method to prevent a child class from overriding it or to the class declaration itself to prevent derivatives.
可以在表单上创建新的提交按钮并把它链接到page类中的一个方法,使用的声明见清单2。
You can create a new submit button on a form and link the button to a method on your Page class using the declaration shown in Listing 2.
在这种情况下,它会将特征中定义的方法实现和字段声明纳入实现特征的类person中。
In this case, it drops the method implementations and field declarations defined in the trait into the class that implements the trait, Person.
正如所看到的,声明summarize方法与声明任何函数的方式一样,只不过它是在类中声明。
As you can see, the summarize method is declared just as any function would be declared, except that is done within a class.
在清单2中,我声明了一个单独的静态方法,接收String参数(通常称为self,但是您可以随意为其命名),代表我向其中添加方法的类。
In Listing 2, I declare a single static method that accepts a String parameter (traditionally called self, but you can call it whatever you like) that represents the class I'm adding the method to.
继承是一种方法,通过它,类的对象可以访问以前精确定义过的类中的成员变量和函数,而不用重新声明那些定义。
Inheritance is the means by which objects of a class can access member variables and functions contained in previously defined class, without having to restate those definitions.
显式的合同是在类方法中,如前提条件后,置条件或不变声明任何合同。
An explicit contract is any contract you declare in a class method, such as a precondition, a postcondition or an invariant.
以下简单示例演示了在基类中声明可从派生类引发的事件的标准方法。
The following simple example shows the standard way to declare events in a base class so that they can also be raised from derived classes.
但是我们依然可以通过反射访问到导出包(exports)中的其他内容,像是包可见类或者private声明的字段和方法。
But it still allowed to use reflection to access everything else in an exported package, like package-visible classes or private fields and methods - this was called deep reflection.
但是我们依然可以通过反射访问到导出包(exports)中的其他内容,像是包可见类或者private声明的字段和方法。
But it still allowed to use reflection to access everything else in an exported package, like package-visible classes or private fields and methods - this was called deep reflection.
应用推荐