Skip to content

Instantly share code, notes, and snippets.

@theleoborges
Created May 18, 2011 13:13
Show Gist options
  • Save theleoborges/978546 to your computer and use it in GitHub Desktop.
Save theleoborges/978546 to your computer and use it in GitHub Desktop.
public enum Clazzes {
param1 ("java.lang.String"),
param2 ("java.util.ArrayList");
private final String clazz;
Clazzes(String clazz) {
this.clazz = clazz;
}
public Object get() throws Exception {
return Class.forName(clazz).newInstance();
}
public static void main(String[] args) throws Exception {
System.out.println(Clazzes.valueOf("param1").get().getClass().getCanonicalName());
System.out.println(Clazzes.valueOf("param2").get().getClass().getCanonicalName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment