Created
September 26, 2012 12:29
-
-
Save nanofi/3787735 to your computer and use it in GitHub Desktop.
Generics Test class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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