Android String Compare compare(String s1, String s2)

Here you can find the source of compare(String s1, String s2)

Description

Comare two string

License

Apache License

Parameter

Parameter Description
s1 string1
s2 string2

Return

result

Declaration

public static int compare(String s1, String s2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//  w  w w.jav a 2 s  .  c  om
     * Comare two string
     * 
     * @param s1
     *            string1
     * @param s2
     *            string2
     * @return result
     */
    public static int compare(String s1, String s2) {
        return s1 == null ? (s2 == null ? 0 : -1) : s1.compareTo(s2);
    }
}

Related

  1. compare(String lhs, String rhs)
  2. compare(String str1, String str2)
  3. compareToIgnoreCase(String s1, String s2, boolean nullsAreGreater)
  4. compareToIgnoreCase(String s1, String s2, boolean nullsAreGreater)