错误:运算符(!=)不能应用于双精度的“ null”。 。怎么修? [英] Error : operator (!=) cannot be applied to double,"null" . How to fix?
本文介绍了错误:运算符(!=)不能应用于双精度的“ null”。 。怎么修?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if(addressList.get(0).getLatitude() != null){
fullAddress += addressList.get(0).getLatitude() + " ";
}
推荐答案
您可以只比较对象类型为 null
You can only compare Object types with null
由于double是基本类型,而不是对象,因此不能将其与<$进行比较c $ c> 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){
}
0
在哪里纬度的默认值。
Where 0
is the default value of Latitude.
查看此 SO 用于正确比较双打。
Check out this SO for comparing doubles properly.
这篇关于错误:运算符(!=)不能应用于双精度的“ null”。 。怎么修?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文