You should remove the second <T>. <T> is to define generics and T is to use generics You need to understand generic classes and generic methods
The <T> on the reason class and the <T> on the method should not appear repeatedly, otherwise it will be considered that the generic type has been redefined on the method.
If you wish
getMax
方法的返回值类型为 T,就要这样去定义getMax
Method:If you want the type of return value of the getMax method to be determined by the caller, then define the
getMax
method like this:The A here must not be the same letter as the T declared in the class name.
In short, the T and <T> T you mentioned are fundamentally two different uses.
You should remove the second <T>.
<T> is to define generics and T is to use generics
You need to understand generic classes and generic methods
The <T> on the reason class and the <T> on the method should not appear repeatedly, otherwise it will be considered that the generic type has been redefined on the method.