Object -> Object[]
Author |
Message |
Zren
|
Posted: Fri Oct 01, 2010 11:34 pm Post subject: Object -> Object[] |
|
|
How would I test, and then convert a Object into an array of Objects?
Edit: Ha hah! I figured it out. Any better solutions?
Java: |
Class classType = obj. getClass(). getComponentType();
if (classType != null) { // Is this an Array of objects?
Object[] objs = new Object[Array. getLength(obj )];
for (int i = 0; i < Array. getLength(obj ); i++ )
objs [i ] = Array. get(obj, i );
}
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Generic
|
Posted: Sun Oct 03, 2010 9:18 pm Post subject: RE:Object -> Object[] |
|
|
Object obj = new Object();
Object[] arr = {obj};
Creates a new Object then initialize an array with one element "obj". |
|
|
|
|
|
|
|