commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <>
Subject Re: [BeanUtils] Handling array creation?
Date Thu, 08 Sep 2005 01:52:25 GMT
If they're always String[] then Thomas's solution is fine - but do you want
to be able to handle other types? LazyDynaBean does something pretty similar
to this - have a look at the growIndexedProperty() method for dynamically
growing arrays and createIndexedProperty() method for instantiating new

Anyway the java.lang.reflect.Array has useful (static) methods for
manipulating arrays...

1) Instantiating an Array

     Object myArray = Array.newInstance(type.getComponentType(), arraySize);

2)  Setting a value in an array, e.g....

     Array.set(myArray, index, value);

3) Finding the length of an array



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message