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;
}
}
if(fld.getType().equals(boolean.class))
Just tested this and it works for primitive boolean
variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With