泛型类
- 网络generic class
-
通配符在类型系统中具有重要的意义,它们为一个泛型类所指定的类型集合提供了一个有用的类型范围。
Wildcards play an important role in the type system ; they provide a useful type bound for the family of types specified by a generic class .
-
例如,在泛型类List中,您真的想要防止List的构造吗?
For example , in a generic class List , do you really want to prevent the construction of a List ?
-
Scala是静态类型的,这就允许它提供泛型类、内部类、甚至多态方法(PolymorphicMethod)。
Scala is statically typed which allows it to provide generic classes , inner classes and even polymorphic methods .
-
在自定义JAVA可重用部件库中构造了支持转换器所用必须的输入流类、泛型类及接口和五种抽象数据类型的两种实现。
In the self-defined JAVA class library , input stream class , generic class , generic interface and five kinds of abstract data type were implement .
-
例如,泛型类JSplitPane可以创建Scrollable的实例。
For example , a generic class JSplitPane may create an instance of Scrollable .
-
将mixin明确表述为泛型类,我们就始终有父类的句柄,它是该类继承的类型参数。
With mixins formulated as generic classes , we always have a handle on the parent class , the type parameter that the class extends .
-
对于新手,Scala中的数组实际上就是泛型类,没有增加“内置”状态(至少,不会比Scala库附带的其他类多)。
For starters , arrays in Scala are effectively generic classes , with no " built-in " status accrued to them ( at least , no more than any other class that ships with the Scala library ) .
-
我们建议您通过定义泛型类最大程度地增强类型的安全性。
We recommend that you maximize type safety by defining a generic class .
-
有时我们想限制可能出现的泛型类的类型实例化。
Sometimes we want to restrict the potential type instantiations of a generic class .
-
泛型类可被视为将它们的参数映射成新实例化的函数。
Generic classes can be viewed as functions mapping their arguments to new instantiations .
-
只要泛型类的运行时实例化没有包括所需的构造函数,就抛出异常。
Throw an exception whenever a run-time instantiation of the generic class does not include a needed constructor .
-
我们对程序可以产生的泛型类的实例化数目设置上限。
We could put an upper limit on the number of instantiations of a generic class that a program can make .
-
因而,在泛型类定义内部,唯一可调用的构造函数是那些在界限中声明的构造函数。
Then , inside the generic class definition , the only constructors that could be called are those declared in the bound .
-
同样,实例化泛型类的客户机类必须使用满足对构造函数存在所声明的约束的类来这样做。
Also , client classes that instantiate our generic class must do so with classes that meet the declared constraint on what constructors exist .
-
处理该问题的另一种方法是:只要泛型类的运行时实例化没有包括所需构造函数,就抛出异常。
Another way of handling this problem would be to throw an exception whenever a run-time instantiation of the generic class does not include a needed constructor .
-
就像泛型类的类型参数用尖括号括起来那样,泛型类型应用程序的参数也是用尖括号括起来的。
Just as the type parameters of a generic class are wrapped in angle brackets , the arguments of a generic type application are wrapped in angle brackets as well .
-
因此,当类型参数T用作泛型类的超类时,T的注释确切地告知我们可以调用哪些超级构造函数。
Thus , when a type parameter T is used as the superclass of a generic class , the annotation on T tells us exactly what super-constructors we can call .
-
在我的DAO实现中,我使用introductions将许多查找器方法添加到现有泛型DAO类中。
In my DAO implementation , I use introductions to add a number of finder methods to my existing generic DAO class .
-
我将结果放到一个泛型集合类中(你可能需要添加System.Collections.Generic引用),然后将结果传递到名为“Categories”的视图中。
I snap the results to a generic collection class ( you may have to add a reference to System . Collections . Generic ) then we pass the results to the view named " Categories " .
-
在框架内部的重要重构使用了泛型集合类代替非泛型的集合性。
Major refactoring internally to use generic collections instead of the non generic types .
-
运行时缺乏类型信息,这给泛型容器类和希望创建保护性副本的泛型类提出了难题。
This lack of type information at runtime poses a problem for generic container classes and for generic classes that want to make defensive copies .
-
在泛型之前设计的类可能阻碍了“显然的”泛型化方法。
Existing classes that were designed before generics may have semantics that resist the " obvious " generification approach .
-
文章首先展示了在Java中使用泛型的语法,包括泛型类、泛型方法以及极具特色的受限类型参数;
Firstly the article gives a description of the syntax of generics in Java , including generic class , generic method and bounded type parameter .