Is there a way to find if a Field is boolean in Java reflection the same as isPrimitive()?
Field fieldlist[] = clazz.getDeclaredFields();
for (int i = 0; fieldlist.length & gt; i; i++) {
Field fld = fieldlist[i];
if (fld.getClass().isPrimitive()) {
fld.setInt(object, 0);
continue;
}
}
Just tested this and it works for primitive
booleanvariables.