Type Variables' bounds can only appear in the declaration of classes, interface, methods and constructors?
Or can I bound a type variable when they are used as type arguments?
Edit: Example:
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?
}
The Java Language Specification seems to agree with you:
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With