lastIndexOf(String str)
int lastIndexOf(String str)
- Returns the index within this string of the rightmost occurrence of the specified substring.
int lastIndexOf(String str, int fromIndex)
- Returns the index within this string of the last occurrence of the specified substring.
public class Main {
public static void main(String[] arg) {
StringBuffer phrase = new StringBuffer("one two three four");
int position = phrase.lastIndexOf("three");
System.out.println(position);
}
}
Home
Java Book
Essential Classes
Java Book
Essential Classes
StringBuffer:
- Create StringBuffer object
- append
- StringBuffer capacity()
- charAt(int index): get the char at specified index
- delete(int start, int end) and deleteCharAt(int index)
- ensureCapacity( )
- getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
- indexOf(String str)
- lastIndexOf(String str)
- StringBuffer length()
- Insert(): add data in the middle of a StringBuffer
- replace():replace a StringBuffer
- StringBuffer reverse()
- setCharAt(int index, char ch)
- setLength
- substring
- toString():Convert StringBuffer to String