

Tests if this string starts with the specified prefix beginning Tests if this string starts with the specified prefix.

Returns the index within this string of the last occurrence of Returns the index within this string of the rightmost occurrence Specified character, searching backward starting at the specified Returns the index within this string of the last occurrence of the Specified substring, starting at the specified index. Specified character, starting the search at the specified index. Returns the index within this string of the first occurrence of the Tell if this object contains a java String object. Tests if this string ends with the specified suffix.Ĭompares this string to the specified object.Ĭompares this string to the specified String.ĮqualsIgnoreCase( anotherString)Ĭonditionally trim all leading and trailing whitespace in the specified String.Ĭopies characters from this string into the destination character Returns the character at the specified index.Ĭompares two strings lexicographically, ignoring case considerations.Ĭoncatenates the specified string to the end of this string.Ĭomment method on the passed LexicalHandler for theĭispatchCharactersEvents( ContentHandler ch)Ĭharacters method on the passed ContentHandler for the By using XMLString, character copies can be reduced This class is meant to be an interface to character strings, whether theyīe java Strings or .FastStringBuffers, or If you had to mix APIs where the end index is sometimes inclusive and sometimes exclusive, this would be error-prone.Interface XMLString All Known Implementing Classes: XMLStringDefault, XString

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

This somehow may also be considered to be in line with things like for-loops, where you usually have for (int i=startIndex i subList(int fromIndex, int toIndex) was inclusive, this would not be the case. One would expect this to yield "true". The second example already shows why the choice to use an inclusive start index and an exclusive end index might be a good idea: It's easy to slice out a substring of a certain length, without having to think about any +1 or -1: int startIndex = 12 The choice of whether the indices are inclusive or exclusive will add some potential for having to fiddle around with a +1 or -1 here and there, but this is not important here. String s = string.substringByIndices(startIndex, startIndex+length) String s = string.substringByLength(startIndex, endIndex-startIndex) At the call site, it's usually trivial to change the call according to the actual semantics of the method: int startIndex =. In both cases, there is another dimension in the design space, namely whether the indices are inclusive or exclusive.įirst of all, note that all versions are basically equivalent. However, from a more general, abstract point of view, it is a valid question, when considering the alternatives: One could imagine two forms of this method: String substringByIndices(int startIndex, int endIndex) Īnd String substringByLength(int startIndex, int length) The question about the "Why" may be considered as philosophical or academic, and provoke answers along the line of "That's just the way it is".
