Here you can find the source of compare(String s1, String s2)
public static int compare(String s1, String s2)
//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(); } }