Name: skT45625 Date: 11/22/2000
java version "1.3"
Submitting for Saieb Khalil <###@###.###>:
Dear sir/madame,
The explaination of the method of the class String, {public int lastIndexOf(String str, int fromIndex)}
was made needlessly complex and misleading by
bad choice of the name of the second parameter. The method scans the
substring -that is defined over the String from index 0 till fromIndex- and
returns the last occurance of the searched substring. The name fromIndex
give the impression that the search begins "from" that index. and because
nowhere in the explaination is mentioned that the search goes backwards, you
would expect that it goes up from "fromIndex" to the end of the string, which is wrong.
While mentioning that it goes "backwards" would solve the problem somehow, I think a
much better solution is to replace the name of the parameter "fromIndex"
with "tillIndex" which would make the range of the search, and the
direction self explanatory.
with regards,
Saieb Khalil
Turnkiek b.v. the Netherlands
> > public int lastIndexOf(String str, int fromIndex)
> > Returns the index within this string of the last occurrence of the
> > specified substring. The returned index indicates the start of the
> > substring, and it must be equal to or less than fromIndex. That is, the
> > index returned is the largest value k such that:
> > this.startsWith(str, k) && (k <= fromIndex)
> >
> > Parameters:
> > str - the substring to search for.
> > fromIndex - the index to start the search from. There is no
restriction
> > on the value of fromIndex. If it is greater than the length of this
string,
> > it has the same effect as if it were equal to the length of this string:
> > this entire string may be searched. If it is negative, it has the same
> > effect as if it were -1: -1 is returned.
> > Returns:
> > If the string argument occurs one or more times as a substring
within
> > this object at a starting index no greater than fromIndex, then the
index of
> > the first character of the last such substring is returned. If it does
not
> > occur as a substring starting at fromIndex or earlier, -1 is returned.
>
(Review ID: 112694)
======================================================================