Source Code : Return generic value from method
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Return generic value from method
import java.io.Serializable;
class Base {
}
class Sub1 extends Base implements Serializable {
public void run() {
}
}
class Sub2 extends Base implements Serializable {
public void run() {
}
}
public class TypeInference {
static <T extends Base> T infer(T t1, T t2) {
return null;
}
public static void main(String[] args) {
Base base = infer(new Sub1(), new Sub2());
Serializable runnable = infer(new Sub1(), new Sub2());
}
}
Thank with us