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.Long
would never be an empty string. If it doesn't have a value means its null
. If queryAllPhoneNumbersForContact(contactId)
returns a long wrapper instance then check phone_temp ==null
, as objects have default value as null.
Long phone_temp = queryAllPhoneNumbersForContact(contactId);
if(phone_temp==null)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.