Is there a way to create an array from a Class
object dynamically using something like
MyClass[].newInstance();
I'm aware that it throws an InstantiationException
, but is there a way for me to instantiate an array indicating its type with a Class
object?
Since java.lang.reflect.Array.newInstance() is not available in J2ME, I think you'd need a loop to do this for each object:
and remember to fully-qualify the name (if you're using stringified class names):
with
Note that the getConstructor() method is not available in the BlackBerry Class, so you're limited to creating objects with no-argument constructors.