I'm now trying to print word's suffixes, and there are some problems.
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.StringBuffer.charAt(Unknown Source)
at _20161212.Launcher.compareSameThings(Launcher.java:67)
at _20161212.Launcher.main(Launcher.java:52)
This is the ErrorCode:
and I'm trying to find the reason, but it's difficult to me.
this
public static void compareSameThings(StringBuffer[] strbuf, int index01, int index02, int count) {
    count++;
    if ((int) strbuf[index01].charAt(count) > (int) strbuf[index02].charAt(count)) {
        StringBuffer temp = strbuf[index01];
        strbuf[index01] = strbuf[index02];
        strbuf[index02] = temp;
    } else if ((int) strbuf[index01].charAt(count) == (int) strbuf[index02].charAt(count)) {
        compareSameThings(strbuf, index01, index02, count);
    }
}
and this
for (int index01 = 0; index01 < str.length() - 1; index01++) {
    for (int index02 = index01 + 1; index02 < str.length(); index02++) {
        int count = 0;
        if ((int) strbuf[index01].charAt(count) > (int) strbuf[index02].charAt(count)) {
            StringBuffer temp = strbuf[index01];
                strbuf[index01] = strbuf[index02];
                strbuf[index02] = temp;
        } else if (strbuf[index01].charAt(count) == strbuf[index02].charAt(count)) {
                compareSameThings(strbuf, index01, index02, count);
        }
    }
}
Can you tell me the reasons why these problems are appearing?
 
     
    