Java lastindexof() method: returns the index position of the last occurrence

Grammar 1

lastIndexOf(int ch)

Example

String strCom = "abcdefg gfdecba";
int index = strCom.lastIndexOf("a");

Grammar 2

lastIndexOf(int ch,int fromIndex)

Example

String strCom = "abcdefg gfdecba";
int index = strCom.lastIndexOf("a",5);

Grammar 3

lastIndexOf(String str)

Example

String strCom="C语言中文网,C语言编程词典,C语言软件";
int index=strCom.lastIndexOf("C语言");

Grammar 4

public int lastIndexOf(String str,int fromIndex)

Example

String strCom="C语言中文网,C语言编程词典,C语言软件";
int index=strCom.lastIndexOf("编程词典",5);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>