I just want to know the concept of lastIndexOf method, i read Java API, i didn't understand. int slash = uri.lastIndexOf("/docs/") + 6; What this will return. Please help.
posted 12 years ago
Well it depends on what your uri String is. The code is valid so you should have had no problems running it.
When the above is ran, i evaluates to 7, and j evaluates to 13. The value of i is the index for the beginning of the String "/docs/", keeping in mind that the first character of s, which is "/", has an index of 0. As the above String is of length 13, that is indexes 0-12, the value for j, 13, is outside the bounds of the String length. HTH.