Rol*_*all 7 java generics methods
Directly from this java tutorial:
For static generic methods, the type parameter section must appear before the method's return type.
Is it not true for NON-static generic method? If not what's the NON-static generic method syntax? Thanks in advance.
Jon*_*oni 10
声明非静态泛型方法的语法与静态方法相同,只是没有static关键字:泛型类型参数放在返回类型之前.
class Example {
public <E> void method(E param) { }
}
Run Code Online (Sandbox Code Playgroud)
非静态方法也可以使用封闭类的泛型类型参数,如下所示.这些不被视为通用方法; 一个通用的方法是一个声明类型参数.
class Example<T> {
// Not a generic method!
public void method(T param) { }
}
Run Code Online (Sandbox Code Playgroud)