This could be quite a stupid question, but I am not sure how to solve this.
int num;
String str;
float flt;
I define three variables, one int, one String and one float. Than I do the following:
Object a = num;
Object b = str;
Object c = flt;
How can I check the a, b or c object for the default value? I know that it is null
for String
, 0
for int
, and 0.0
for float
, but is there a way to do some sort of:
if(a==nullValue(a) && b==nullValue(b) && c==nullValue(c))
so that it is equal to:
if(a==0 && b==null && c==0.0)
I just get the three a, b, c objects passed and so I don't know which type they are.
if o.getClass().isPrimitive() then if clazz.equals(int.class) then return 0 ... and others else if not primitive return null
o.getClass().isPrimitive()
will never returntrue
in this case.