Java - Strings Class-String lastIndexOf(String str) Method - Java

Description

This method accepts a String as an argument, if the string argument occurs one or more times as a substring within this object, then it returns the index of the first character of the last such substring is returned. If it does not occur as a substring, -1 is returned.

Syntax

Here is the syntax of this method −

Parameters

Here is the detail of parameters −

  • str − a string.

Return Value

This method returns the index.

Example


This will produce the following result −

Output

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Java Topics