By jj83777
via tutorials.jenkov.com
Published: Sep 04 2008 / 06:44
Text no. 11 in the Java Reflection series describes how to create and access arrays via Java Reflection. Especially obtaining the class object of an array via reflection can be tricky, if you don't know how.
Comments
Jakob Jenkov replied ago:
Forget the link above... it points to localhost... suprising that Dzone doesn't detect that. Here is the real link:
http://tutorials.jenkov.com/java-reflection/arrays.html
bloid replied ago:
this one's fixed now
Jakob Jenkov replied ago:
except the dzone URL is off... java_reflection_tutorial_introduction.html
Jakob Jenkov replied ago:
except the dzone URL is off... java_reflection_tutorial_introduction.html
raveman replied ago:
nice find, but its useless? i would use list.
Jakob Jenkov replied ago:
I would use List too in most cases, when I can. But you can't always make that choice yourself, can you? For instance, when configuring an app via DI, sometimes you have to inject arrays into some classes that you did not write yourself.
eyal.lupu replied ago:
Nice post, just a comment: There is a way to access natives array classes using reflection. I wrote a short follow up about it in my blog: http://www.jroller.com/eyallupu/entry/two_side_notes_about_arrays
Voters For This Link (14)
Voters Against This Link (0)