如果让你判断一个文本框是否为空(null)或者没有任何值(length=0),你会怎么怎样去写代码,很多初学者可能会这样写: if(text==null || text.length==0) {........} 其实没有必要这么麻烦,在android的官方API中有更方便的解决方法:Returns true if the string is null or 0-length,可以使用这个方法-TextUtils.isEmpty() 可以这样写: if(!TextUtils.isEmpty(te…
写在前面 不知大家有没遇到过像"横放着的金字塔"一样的if else嵌套: if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { } } } } } } 我并没夸大其词,我是真的遇到过了!嵌套6.7层,一个函数几百行,简!直!看!死!人! if else作为每种编程语言都不可或缺的条件语句,我们在编程时会大量的用到.但if else一般不建议嵌套超过三层,如果一段代码存在过多的if else嵌套,…