aspose file tools*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String Class Method " Watch "String Class Method " New topic
Author

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
Sheriff

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: String Class Method