Skip to tool

Java String.lastIndexOf() Online

Find last index of a substring.

The output updates as you type. The tool processes input in your browser.

Worked example

A repeated substring can have different first and last positions. Browser offsets start at zero.

Needle
"manuals"
Sample input
manuals plus manuals
Sample output
13

Using this operation in Java

The interactive result uses JavaScript. String indexes count UTF-16 code units. Use codePoints() when iterating supplementary Unicode characters and Locale.ROOT for locale-independent casing.

Java reference