It's confusing because type declaration and usage both use the
<T> syntax. I think there are only 2 places where you can declare new generic types in Java:
1. In the definition of a class or interface
class MyClass<T> ... // ^^^- Type declaration interface MyInterface<T,U> ... // ^^^^^- Declaring 2 types
2. Before a static method
// The declared type must then be used as a parameter of that method... static <T> void foo(T t... // ^^^ // or as the return type: static <T> T foo(... // ^^^
Is that true? Am I using the right words? Should I say "introduce" a type variable instead of "declare?" Things like the following statement worry me:
It is possible for a constructor to be generic independently of whether the class the constructor is declared in is itself generic.
I'm trying to write up the limits of Java generics, but I'm only just getting started.