K
Karl Koster
I am trying to construct a method that will take a class and a
collection of instances of that class and construct an array of that
class using reflection.
I cannot just use to the .toArray() method of the collection because
this returns an array of Object that cannot be cast to an array of the
class that was passed to the method.
I have gotten to the point of loading the appropriate array class
name. (i.e. "[" followed by the appropriate class information)
However, there are no constructors defined for these classes when
using reflection. It would have been nice if a constructor with a
single integer paramater where there, but it is not.
I have been batting this around for a few hours and have not found any
solution. If anyone is aware of a way to do this, I would greatly
appreciate knowing how it was accomplished.
collection of instances of that class and construct an array of that
class using reflection.
I cannot just use to the .toArray() method of the collection because
this returns an array of Object that cannot be cast to an array of the
class that was passed to the method.
I have gotten to the point of loading the appropriate array class
name. (i.e. "[" followed by the appropriate class information)
However, there are no constructors defined for these classes when
using reflection. It would have been nice if a constructor with a
single integer paramater where there, but it is not.
I have been batting this around for a few hours and have not found any
solution. If anyone is aware of a way to do this, I would greatly
appreciate knowing how it was accomplished.