Android examples for java.lang:String Equals
String equals Ignore Case and handle null value
import java.net.MalformedURLException; import java.net.URL; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ /**/*w w w . j a va 2s. c o m*/ * <pre> * StringUtil.equalsIgnoreCase(null, null) = true * StringUtil.equalsIgnoreCase(null, "") = false * StringUtil.equalsIgnoreCase("", null) = false * StringUtil.equalsIgnoreCase(null, "han") = false * StringUtil.equalsIgnoreCase("han", null) = false * StringUtil.equalsIgnoreCase("han", "han") = true * StringUtil.equalsIgnoreCase("han", "HAN") = true * </pre> * */ public static boolean equalsIgnoreCase(String str1, String str2) { return str1 == null ? str2 == null : str1.equalsIgnoreCase(str2); } }