Skip to content Skip to sidebar Skip to footer

Error : Operator (!=) Cannot Be Applied To Double,"null" . How To Fix?

if(addressList.get(0).getLatitude() != null){ fullAddress += addressList.get(0).getLatitude() + ' '; }

Solution 1:

You can only compare Object types with null

Since double is a primitive and not an Object you cannot compare it with null. Compare it with number:

if(addressList.get(0).getLatitude() != 0){

}

Where 0 is the default value of Latitude.

Check out this SO for comparing doubles properly.

Post a Comment for "Error : Operator (!=) Cannot Be Applied To Double,"null" . How To Fix?"