Created
January 16, 2013 15:46
-
-
Save justinwyer/4548112 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 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. | |
} | |
return null; | |
} | |
private static <T, U extends Class<Foo>> T doStuff(U clazz) { | |
return readValue("Hello", clazz); | |
} | |
public static void main(String[] args) { | |
doStuff(Bar.class); | |
} | |
} | |
class Foo { | |
} | |
class Bar { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment