<

I just announced the new Spring 5 modules in REST With Spring:

>> CHECK OUT THE COURSE

The method lastIndexOf() returns the index of the last occurrence of a String in another String. If an int is passed to the method, then the method searches for the Unicode character equivalent.

We can also pass the index of the character to start searching from.

Available Signatures

public int lastIndexOf(int ch)
public int lastIndexOf(int ch, int fromIndex)
public int lastIndexOf(String str)

Example

@Test
public void whenCallLastIndexOf_thenCorrect() {
    assertEquals(2, "foo".lastIndexOf("o"));
    assertEquals(2, "foo".lastIndexOf(111));
}
Next »
Java String.regionMatches()
« Previous
Java String.isEmpty()

I just announced the new Spring 5 modules in REST With Spring:

>> CHECK OUT THE LESSONS