Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nanofi
Created September 26, 2012 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanofi/3787735 to your computer and use it in GitHub Desktop.
Save nanofi/3787735 to your computer and use it in GitHub Desktop.
Generics Test class
public class Test{
public static interface FA<T extends Runnable> {
void hello();
T get();
}
public static interface FB {
void world();
}
public static interface FC {
void exq();
}
public static class Method {
public <T extends FA<? super T>> void method(T a) {
a.hello();
System.out.println();
a.get().run();
}
public <T extends FB & FC> void method(T a) {
System.out.print(" ");
a.world();
System.out.print(" ");
a.exq();
System.out.println();
}
}
private static class TestA implements FA<TestA>, Runnable {
public void hello() {
System.out.print("Hello");
}
public TestA get(){
return new TestA();
}
@Override
public void run() {
System.out.println("ddddd");
}
}
private static class TestBC implements FB, FC {
public void hello() {
System.out.print("Hello");
}
public void world() {
System.out.print("World");
}
public void exq() {
System.out.print("!");
}
}
public static void main(String[] args) {
Method method = new Method();
method.method(new TestA());
method.method(new TestBC());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment