java.lang.StringBuffer indexOf(String str)


public int indexOf(String str)

Java Code Example :

This java example source code demonstrates the use of indexOf(String str) method of StringBuffer class. Initially the code assigns a string “” as initial contents of the string buffer. Then we use the indexof method to get the starting index of string “.com”.

This is very useful to work with substring method of StringBuffer class. On this example we will also learn how to use the indexof method to work with substring.

Sample Output :

Running the above example source code will give the following output

indexOf(String str) method example

indexOf(String str) method example

Suggested Reading List :

References :