remotepath != null 与 !TextUtils.isEmpty(remotepath) 的差别

remotepath != null   与 !TextUtils.isEmpty(remotepath) 的差别


 !TextUtils.isEmpty(remotepath)    与   remotepath != null &&remotepath.length > 0   一样


或者初始化 remotepath = null。这时仅仅推断 remotepath != null 也能够,假设初始化 remotepath = “” ,这时必须 用!TextUtils.isEmpty(remotepath) 推断


能够单独写个java main 方法检验


public class Test {

private static String str = "";
/**
* @param args
*/
public static void main(String[] args) {
setText();
}
public static void setText(){  
       if(str != null)  
           System.err.println("daying");
   } 
}

原文地址:https://www.cnblogs.com/hrhguanli/p/5086828.html