compare static method

int compare(
  1. String str1,
  2. String str2
)

比较两个字符串是否相同

Implementation

static int compare(String str1, String str2) {
    if (str1 == str2) {
        return 0;
    }
    if (str1 == null || str2 == null) {
        return str1 == null ? -1 : 1;
    }
    return str1.compareTo(str2);
}