Android examples for java.lang:String Equals
Check two string for equal, handle reference comparison and null value
import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.regex.Pattern; public class Main{ public static boolean equal(String a, String b) { return a == b || (a != null && b != null && a.length() == b.length() && a .equals(b));// w w w . j a va 2s. c om } }