A DESCRIPTION OF THE PROBLEM : The bug concerns the description of the method public int indexOf(String str, int fromIndex) in the class StringBuffer. In the documentaion we can see following misleading lines: === The integer returned is the smallest value k for which: k >= Math.min(fromIndex, str.length()) && this.toString().startsWith(str, k) If no such value of k exists, then -1 is returned. === This statement is wrong. For example, consider this code: StringBuffer sb = new StringBuffer( " deabcabab " ); String str = " ab " ; int fromIndex = 6; int k = 2; System.out.println(k >= Math.min(fromIndex , str.length())); System.out.println(sb.toString().startsWith(str,k)); System.out.println(k < sb.indexOf(str, fromIndex)); System.out.println(sb.indexOf(str, fromIndex)); output: === true true true 7 === EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - === The integer returned is the smallest value k for which: k >= Math.min(fromIndex, this.length()) && this.toString().startsWith(str, k) === cf. with the description of indexOf for String. ACTUAL - === The integer returned is the smallest value k for which: k >= Math.min(fromIndex, str.length()) && this.toString().startsWith(str, k) If no such value of k exists, then -1 is returned. === URL OF FAULTY DOCUMENTATION : http://docs.oracle.com/javase/6/docs/api/java/lang/StringBuffer.html