Created
January 20, 2011 07:04
-
-
Save zaki50/787518 to your computer and use it in GitHub Desktop.
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
class Klass<K> { | |
public static <K> Klass<K> create(Class<K> c) { | |
return new Klass<K>(c); | |
} | |
private final Class<K> clazz; | |
private Klass(Class<K> c) { | |
clazz = c; | |
} | |
public K get() { | |
return clazz.newInstance(); | |
} | |
} | |
Klass<String> k = Klass.create(String.class); | |
String s = k.get(); | |
とか | |
Klass<? extends CharSequence> k = Klass.create(String.class); | |
CharSequence s = k.get(); | |
みたいな使い方になるかと... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment