How to get base type of a multidimensional array in reflection
If I have a Field I can get use Class<?> c = field.getType() to get it's Class but I don't know how to get the array type easily. For example:
<code>
Class cls {
float[][] flt;
}
Field[] f = cls.class.getDeclaredFields();
Class<?> c = f[0].getType;
</code>
I can get "[[F" representing the declaration in reflection, but how can I get "F" representing the primitive type float? I have the same question for a reference to a multidimensional array of classes.
The only thing that I can think of is to parse the string in c.getCanonicalName() or c.getComponentType() to find the representative type and then determine if it's a primitive or class. If it's a class then create an object of that class (<>.newInstance()) and then do something with the object. Is there an easier way?