java generic generic interface (Generic Methods) type parameters (Type Parameters)

Static methods, non-static methods, and constructors can all use type parameters. The
method or the type parameter of the constructor acts on the entire method without exception. Because the method has no static part

//1.静态方法
static <T extends String> void staticMethod( T t) {
    
    }

//2.非静态方法
<T extends String> void staticMethod( T t) {
    
    }

Reference:
http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#FAQ301
http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedMethods.html

Guess you like

Origin blog.csdn.net/claroja/article/details/114108665