aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes .lastIndexOf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark ".lastIndexOf" Watch ".lastIndexOf" New topic
Author

.lastIndexOf

Tim Holmes
Greenhorn

Joined: Aug 26, 2005
Posts: 25
I am trying to undestand what is going on here:



I know that it is starting at index 10 and figured out that is zero based so it is starting at the "n" of the second "One". Then it counts backwards to find the the last occurrence of "One". The example I am looking at says it is "9", but if i count backwards like when finding the starting index, the "n" of the second "One" is zero and 9 is the "n" of the first "One". Right?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18990
    
  40

but if i count backwards like when finding the starting index, the "n" of the second "One" is zero and 9 is the "n" of the first "One". Right?


No. The index of the characters doesn't change -- the index is the index relative from the beginning starting from zero. I don't know about you but it would really be confusion if the index is based on how the method is called.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Tim Holmes
Greenhorn

Joined: Aug 26, 2005
Posts: 25
Ah that makes sense...thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: .lastIndexOf