Reflection using Primitive types
Hi all,
I need to call a method using reflection which takes and array of primitive double objects and I am getting a class cast exception. I am using a convertTypes method to try to return a double[] class. I know primitives are not classes in Java so how can I achieve this?
Method method = collectionClass.getMethod("setAll"+columnNames[i], convertTypes(columnTypes[i]));
method.invoke(this, columnValues[i]);
private Class[] convertTypes(Object columnType){
String colType = (String)columnType;
if (colType.equalsIgnoreCase("int"))
{
returnnew Class[]{Integer.class};
}
elseif (colType.equalsIgnoreCase("float"))
{
returnnew Class[]{double[].class};
//return new Double[]{Double.TYPE};
//return double[].class;
//return double[].class;
}
elseif (colType.equalsIgnoreCase("varchar"))
{
returnnew Class[]{String[].class};
}
returnnull;
}

