I have
Field f = this.getClass().getFields()[0];
I need to know if f
\'s value in this
is null
or not
field.get(target) returns Object
. So you can checkif (field.get(this) == null) {..}
If the field is primitive, it will get wrapped. int
-> Integer
, char
-> Character
, etc.
You need to get the field from the object then check if it is null
Field f = this.getClass().getFields()[0];
if (f.get(this) == null)
...
You didn't search well enough: http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Field.html#get%28java.lang.Object%29
Call this method, and check if the returned object is null.
use Object obj=f.get(this)
and check whether the returned object(in this case obj) is null or not