Tuesday 8 July 2014

lastIndexOf (String str, int fromIndex)

public synchronized int lastIndexOf(String str, int fromIndex)
Return the index within this sequence of the last occurrence of the specified substring from the fromIndex.

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", 7));
    }
}

Output
Last index of "ert" is 4



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment