Yes, static method can be generic.
classGenericStaticMethod {
static <T> T method(T t) {
return t;
}
public static voidmain(String[] args) {
String s=GenericStaticMethod.<String> method("static generic");
System.out.print(s);
}
}
Output:
static generic
No comments:
Post a Comment