how can you check the length of if an array with is a class field?
Array.getLength(?) doesn't seem to be working for me
~
Here is a piece of demo code I quickly scratch
~
import java.util.*;
import java.lang.reflect.*;
// __
class KAI{
public String a;
public int i;
public long[] lAr;
public byte[] bAr;
}
// __
class KAX{
private String a00;
private final String a04 = "04";
private final int[] iAr = new int[]{0, 1, 2};
public long l00;
public String[][] sSAr = new String[][]{{"a","b"},{"0","1","2"}};
public ArrayList<String> ALS;
KAI[] KAIAr = new KAI[2];
}
// __
class KFlds00{
KFlds00(){}
// __
public void printKFieldsAttrs(Object Obj){
// __
try{
Field Flds[] = (Obj.getClass()).getDeclaredFields();
for (int j = 0; j < Flds.length; ++j){
Flds[j].setAccessible(true);
System.out.println("// __ Flds[" + j + "]: |" + Flds[j].getName()
+ "|, |" + Flds[j].getModifiers() + "|" +
Modifier.toString(Flds[j].getModifiers()) + "|" +
Flds[j].getDeclaringClass() + "|");
// __
Class KTp = Flds[j].getType();
if (KTp.isArray()) {
Class CompTp = KTp.getComponentType();
System.out.println("// __ Array of: |" + CompTp + "|");
System.out.println("// __ isPrimitive: |" + CompTp.isPrimitive()
+ "|");
// System.out.println("// __ Array size: |" + Array.getLength(?) +
"|");
}
else{
System.out.println("// __ " + KTp + "|" + Flds[j].get(Obj) +
"|");
}
}
}catch(InstantiationException InstX){ InstX.printStackTrace(); }
catch(IllegalAccessException IlgAxX){ IlgAxX.printStackTrace(); }
// __
}
}
// __
public class KFlds00Test{
public static void main(String[] aArgs){
KAI K = new KAI();
KFlds00 KFlds = new KFlds00();
KFlds.printKFieldsAttrs(K);
// __
KAX KX = new KAX();
KFlds.printKFieldsAttrs(KX);
}
}