Skip to content

Instantly share code, notes, and snippets.

@justinwyer
Created January 16, 2013 15:32
Show Gist options
  • Save justinwyer/4547988 to your computer and use it in GitHub Desktop.
Save justinwyer/4547988 to your computer and use it in GitHub Desktop.
public class Main {
private class Foo {
}
private static <T> T readValue(String response, Class<T> returnType) {
try {
return returnType.newInstance();
} catch (InstantiationException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (IllegalAccessException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
private static <T, U extends Class<T>> T doStuff(U clazz) {
return readValue("Hello", clazz);
}
public static void main(String[] args) {
System.out.println(doStuff(Foo.class));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment