Google+

Like Us On Facebook


Total Pageviews

138. Using 'lastIndexOf( )' method







lastIndexOf( ) method searches Index value for the last occurrence of a character or a substring.

Examples:

"This is a test statement of a person".lastindexOf('a')  -> searches index value for the last occurrence of character 'a'.
"This is a test statement of a test person".lastindexOf("test") -> searches index value for the last occurrence of substring "test"

Lets implement this on Eclipse IDE:

1. Create 'lastIndexOfDemo' class under any project as shown below:



2. Save and Run the 'lastIndexOfDemo' class file
3. Observe that the output is displayed in the console as shown below:



Download this project:

Click here to download the project containing the class file used in this post (You can download this project and import into Eclipse IDE on your machine)



Please comment below to feedback or ask questions.

Using 'substring( )' method will be explained in the next post.



No comments:

Blog Index