Java - Write code to get the last Index Of Letter in a string

Requirements

Write code to get the last Index Of Letter in a string

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String string = "book2s.com123123123";
        System.out.println(lastIndexOfLetter(string));
    }//  w  ww . j  ava  2 s  .c  om

    public static int lastIndexOfLetter(String string) {
        for (int i = 0; i < string.length(); i++) {
            char character = string.charAt(i);
            if (!Character.isLetter(character) /*&& !('_'==character)*/)
                return i - 1;
        }
        return string.length() - 1;
    }
}