小编Hot*_*ean的帖子

运算符 != 不能应用于 double、null

我在下面的代码中遇到错误:

  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);
Run Code Online (Sandbox Code Playgroud)

他们说要添加:

在创建 hashMap 之前或针对每个纬度和经度执行if(pickupLatLng.latitude != null &&pickupLatLng.longitude != null && destinationLatLng.latitude != null && destinationLatLng.longitude != null) 。

但是当我尝试这个时,我收到以下错误:operator !=无法应用于 double, null

有人能帮助我吗 ?

double null android latitude-longitude uber-api

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

double ×1

latitude-longitude ×1

null ×1

uber-api ×1