java为什么跳过我的IF语句?
我的安卓应用程序正在跳过IF语句:
Geocoder gcd = new Geocoder(this, Locale.UK);
List<Address> addresses = gcd.getFromLocation(curLatitude, curLongitude,1);
if (addresses.size() > 0) //this is skipped
{
StringBuilder cityName = new StringBuilder();
cityName.append(addresses.get(0).getLocality());
CityName = cityName.toString();
由于一些未知的原因,它昨天和今天都运转良好。你能告诉我为什么吗
# 1 楼答案
看看这里: https://code.google.com/p/android/issues/detail?id=38009
# 2 楼答案
您的addresses对象可能存在以下问题1)addresses可能为空,因此可能会发生nullpointer异常2)您的addresses列表没有元素,因此可能会始终返回0