Android String Compare compare(String s1, String s2)

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

Description

compare

Declaration

public static int compare(String s1, String s2) 

Method Source Code

//package com.java2s;

public class Main {
    public static int compare(String s1, String s2) {
        if (isNullOrEmpty(s1) && isNullOrEmpty(s2)) {
            return 0;
        } else if (isNullOrEmpty(s1)) {
            return 1;
        } else if (isNullOrEmpty(s2)) {
            return -1;
        }/*from  w  w w  .j  a va  2 s  . c  o m*/

        return s1.compareToIgnoreCase(s2);
    }

    public static boolean isNullOrEmpty(String input) {
        if (input == null) {
            return true;
        }

        return input.trim().isEmpty();
    }
}

Related

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