【发布时间】:2015-07-18 03:21:49
【问题描述】:
阅读此代码时遇到问题。
为什么编码器会确定allProvinces = null?
if(!TextUtils.isEmpty(response)){
String [] allProvinces = response.split(",");
/* how should I check whether allProvinces is null or not?
* it means the method "split" can possibly return a null value?
*/
if( allProvinces != null && allProvinces.length > 0){
for(String p :allProvinces) {
String [] array = p.split("//|");
Province province = new Province();
province.setProvinceName(array [0]);
province.setProvinceCode(array[1]);
weatherDb.saveProvince(province);
}
}
}
【问题讨论】:
标签: android android-layout android-fragments android-intent android-activity