Sunday, 6 July 2014

indexOf (String str)

public int indexOf(String str)
Returns the index within this string of the first occurrence of the specified substring.

public class StringBufferIndexOf {
     public static void main(String args[]){
        StringBuffer str1 = new StringBuffer("Hi How are you");
        System.out.print("Index of \"How\" is ");
        System.out.println(str1.indexOf("How"));
    }           
}

Output
Index of "How" is 3



 
Prevoius                                                 Next                                                 Home

No comments:

Post a Comment