Check two string for equal, handle reference comparison and null value - Android java.lang

Android examples for java.lang:String Equals

Description

Check two string for equal, handle reference comparison and null value

Demo Code

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
    }

}

Related Tutorials