Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

operator != cannot be applied to double, null

I am getting an error on this code below:

  HashMap map = new HashMap();
  map.put("driver", userId);
  map.put("customer", customerId);
  map.put("rating", 0);
  map.put("timestamp", getCurrentTimestamp());
  map.put("destination", destination);
  map.put("location/from/lat", pickupLatLng.latitude);
  map.put("location/from/lng", pickupLatLng.longitude);
  map.put("location/to/lat", destinationLatLng.latitude);
  map.put("location/to/lng", destinationLatLng.longitude);
  map.put("distance", rideDistance);
  historyRef.child(requestId).updateChildren(map);

They said to add:

do if( pickupLatLng.latitude != null && pickupLatLng.longitude != null && destinationLatLng.latitude != null && destinationLatLng.longitude != null) before creating the hashMap, or for each latitude and longitude.

But when i try this i am getting the following error: operator != cannot be applied to double, null

Can someone help me please ?

like image 984
Hotcaribbean Avatar asked Oct 25 '25 18:10

Hotcaribbean


1 Answers

double is a primitive type, it cannot be null, instead you can use Double and then compare it to null

like image 78
Suleyman Avatar answered Oct 28 '25 07:10

Suleyman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!