Computer Science, asked by FreeBird27, 11 months ago

Explain with example what is int lastIndexOf (char ch) in java​

Answers

Answered by shubham0204
2

Answer:

See below.

Explanation:

Suppose, we have a String,

String name = "shubham"

Note that in the name, the letter 'h' has two occurrences. The first is at index 1 and the second is at index 4.

Now, we use,

int lastIndex = name.lastIndexOf( "h" )

Now, the value of lastIndex will be 4 instead of 1. It returned the last index of letter "h" in the string.

Similar questions