public class Main {
/*时 代 J a v a 公 众 号 - nowjava.com 提供*/
public static void main(String[] args) {
//declare a String object
String strOrig = "Hello world Hello World";
int intIndex = strOrig.indexOf("Hello");
if(intIndex == - 1){
System.out.println("Hello not found");
}else{
System.out.println("Found Hello at index " + intIndex);
}
int positionIndex = strOrig.indexOf("Hello",11);
System.out.println("Index of Hello after 11 is " + positionIndex);
//from 时 代 J a v a
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。