In my class I have this parameter:
public Long label_id ;
When I try to evaluate the value from label_id which is 0
if(item.label_id == new Long(0)) {
Doesn't enter here
} else {
Enters here
}
It is supposed to enter the condition since both are zero but it enters the else condition. I even tried debugging the code:
label_id Long (id=142)
value 0
Am I missing something here?
You should extract the value of label_id
first and then compare it:
if(item.label_id.longValue() == 0L)
You are using an object comparison. and with new ... you generate a new object. the both objects are not the same... You can use new Long(0).equals(...)
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