Created
January 16, 2013 15:32
-
-
Save justinwyer/4547988 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
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