类型变量的边界只能出现在类、接口(interface)、方法和构造函数的声明中吗?
或者当类型变量用作类型参数时我可以绑定(bind)类型变量吗?
编辑: 示例:
class MyClass<T extends Number> { // T is bounded by the interface Number
// can a bounded Type Parameter appear anywhere else,
// besides the Type parameter declaration?
}
最佳答案
Java Language Specification似乎同意你的观点:
A type variable (§4.4) is an unqualified identifier. Type variables are introduced by generic class declarations (§8.1.2) generic interface declarations (§9.1.2) generic method declarations (§8.4.4) and by generic constructor declarations (§8.8.4).
关于java - 在 Java 中,类型变量的边界只能出现在类型变量声明中,对吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4774585/