Android String Equal equals(String str1, String str2)

Here you can find the source of equals(String str1, String str2)

Description

Comparing two strings, returns true if they are equal, if both are null -> result == true

License

Open Source License

Parameter

Parameter Description
str1 first string to compare, can be null
str2 second string to compare, can be null

Return

true if string are equal or if both of references are null, compare is case sensitive

Declaration

public static boolean equals(String str1, String str2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   ww  w .  ja  v a  2s  .c  o  m*/
     * Comparing two strings, returns true if they are equal, if both are null -> result == true
     *
     * @param str1
     *          first string to compare, can be null
     * @param str2
     *          second string to compare, can be null
     * @return true if string are equal or if both of references are null, compare is case sensitive
     */
    public static boolean equals(String str1, String str2) {
        if (str1 == null) {
            return str2 == null;
        }

        return str1.equals(str2);
    }
}

Related

  1. equals(String str1, String str2)
  2. equalsIgnoreCase(String str1, String str2)
  3. isEquals(String a, String b)
  4. equals(final CharSequence cs1, final CharSequence cs2)
  5. equal(String s1, String s2)
  6. isEquals(String str1, String str2)
  7. equals(String str1, String str2)
  8. equalsIgnoreCase(String str1, String str2)