code: public static int indexOfDifference(String str1, String str2) {
        if (str1 == str2) {
            return -1;
        }
        if (str1 == null || str2 == null) {
            return 0;
        }
        int i;
        for (i = 0; i < str1.length() && i < str2.length(); ++i) {
            if (str1.charAt(i) != str2.charAt(i)) {
                break;
            }
        }
        if (i < str2.length() || i < str1.length()) {
            return i;
        }
        return -1;
    }
docs: <p>Compares two Strings, and returns the index at which the
  Strings begin to differ.</p>
  
  <p>For example,
  <code>indexOfDifference("i am a machine", "i am a robot") -> 7</code></p>
  
  <pre>
  GosuStringUtil.indexOfDifference(null, null) = -1
  GosuStringUtil.indexOfDifference("", "") = -1
  GosuStringUtil.indexOfDifference("", "abc") = 0
  GosuStringUtil.indexOfDifference("abc", "") = 0
  GosuStringUtil.indexOfDifference("abc", "abc") = -1
  GosuStringUtil.indexOfDifference("ab", "abxyz") = 2
  GosuStringUtil.indexOfDifference("abcde", "abxyz") = 2
  GosuStringUtil.indexOfDifference("abcde", "xyz") = 0
  </pre>
  
  @param str1  the first String, may be null
  @param str2  the second String, may be null
  @return the index where str2 and str1 begin to differ; -1 if they are equal
  @since 2.0