Skip to content

Instantly share code, notes, and snippets.

@dushmis
Created August 20, 2013 19:03
Show Gist options
  • Save dushmis/6285763 to your computer and use it in GitHub Desktop.
Save dushmis/6285763 to your computer and use it in GitHub Desktop.
Create an array using Java reflection api
try {
Class cls = Class.forName("java.lang.String");
Object arr = Array.newInstance(cls, 10);
Array.set(arr, 5, "test string..");
String s = (String)Array.get(arr, 5);
System.out.println(s);
}catch (Throwable e) {
System.err.println(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment