I am trying to unpack an array I obtain from reflecting an objects fields. I set the value of the general field to an Object. If it is an Array I then want to cast my general Object to an array (no matter what its type) and extract its content
fields[i].setAccessible(true);
String key = fields[i].getName();
Object value = fields[i].get(obj);
if (value.getClass().isArray()){
unpackArray(value);
}
In my unpackArray method, I have tried casting the Object Value to java.util.Arrays, java.reflect.Array and Array[] but each time it is not letting me.
Is there a way I can cast my Object to a generic array?
Many Thanks Sam