What does this use of Java generics mean?
•
Java
I want to know that the first < T > represents the following java code line I've read several tutorials on generics, but none of the examples have two generics before the method name thank you.
public <T> Provider<T> scope(Key<T> key,Provider<T> unscoped);
Solution
The first < T > is the actual type parameter declaration, that is, it means that the method is generic and has a type parameter t
The second < T > is only part of the method return type, that is, the method returns provider < T >
If the first < T > is omitted, the return type provider < T > will be invalid because t is not an identifiable identifier / name of the type T is only recognized as a type because the first < T > describes it this way
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码