使用“!”操作符进行null检查。例如:
String str = null; if(!str.isEmpty()){ // do something } else { // handle null condition }
而使用not()操作符时,需要使用额外的null检查。例如:
String str = null; if(str != null && !str.isEmpty()){ // do something } else { // handle null condition }
上一篇:AndroidStudio:设计中显示的图片在设备上无法显示
下一篇:AndroidStudio:使用SQLITE数据库进行公共交通路线导航搜索。