[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String.indexOf
From: |
Patrick Doyle |
Subject: |
Re: String.indexOf |
Date: |
Sat, 18 Aug 2001 18:57:00 -0400 (EDT) |
On 18 Aug 2001, John Keiser wrote:
> On 08 Aug 2001 14:15:14 -0400, Patrick Doyle wrote:
> >
> > +++ String.java Wed Aug 8 14:04:28 2001
> > @@ -688,7 +689,7 @@
> > */
> > public int indexOf(String str, int fromIndex) throws
> > NullPointerException {
> > if (fromIndex < 0) fromIndex = 0;
> > - for (int i = fromIndex; i < count; i++)
> > + for (int i = fromIndex; i <= count; i++)
> > if (regionMatches(i, str, 0, str.count))
> > return i;
> > return -1;
> > @@ -735,7 +736,7 @@
> > * @exception NullPointerException if `str' is null
> > */
> > public int lastIndexOf(String str) throws NullPointerException {
> > - return lastIndexOf(str, count-1);
> > + return lastIndexOf(str, count);
> > }
>
> I assume the sole purpose of this change is to make it so that a person
> can call lastIndexOf("") and have it return count?
>
> I can't think of any other effect the code could possibly have.
Yes, that was the reason I made the change. I was unsure whether there
are any other side-effects which make this change undesirable; but now
that I think about it more, it seems that this change could only possibly
affect empty search strings.
--
Patrick Doyle
address@hidden