Tuesday, 8 July 2014

lastIndexOf (String str)

public int lastIndexOf(String str)
if the string argument occurs one or more times as a substring within this object, then the index of the first character of the last such substring is returned. If it does not occur as a substring, -1 is returned.

public class StringBufferLastIndexOf {
    public static void main(String args[]){
        StringBuffer str = new StringBuffer("wertertwertdef");
        System.out.print("Last index of \"ert\" is ");
        System.out.println(str.lastIndexOf("ert"));
    }
}

Output
Last index of "ert" is 8




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment