wood burning stoves
The moose likes Beginning Java and the fly likes String Class Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String Class Method " Watch "String Class Method " New topic

String Class Method

Deepak Chawla
Ranch Hand

Joined: Nov 19, 2003
Posts: 50
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.
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: String Class Method
It's not a secret anymore!