Explain with example what is int lastIndexOf (char ch) in java
Answers
Answered by
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
Psychology,
6 months ago
Math,
6 months ago
Science,
11 months ago
Music,
1 year ago
Physics,
1 year ago