I have a Long field in java.I need to test whether this field has a value or not.I am using the following code:
Long phone_temp = queryAllPhoneNumbersForContact(contactId);
if(phone_temp.equals(""))
{
System.out.println("Value is null",""+phone_temp);
}
Long has a null value however when i try to print the value of phone_temp it gives app crashed.How do i check whether phone_temp has a value.
java.lang.Longwould never be an empty string. If it doesn’t have a value means itsnull.If
queryAllPhoneNumbersForContact(contactId)returns a long wrapper instance then checkphone_temp ==null, as objects have default value as null.