public class Main { public static void main(String[] argv) throws Exception { String string = "I am Java"; int index = string.lastIndexOf("z"); // -1 } }