int indexOf(String str) 
          Returns the index within this string of the first occurrence of the specified substring. 
 int indexOf(String str, int fromIndex) 
          Returns the index within this string of the first occurrence of the specified substring, starting at the specified index. 

解决方案 »

  1.   


     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, searching backward starting at the specified index. 
      

  2.   

    String s="aaaaa1bbbbb";
    int i=s.indexOf("1");
    parentString.indexOf(childString);得到的是在字符串parentString中子字符串第一次出现的位置i
      

  3.   

    for more infomation, seehttp://java.sun.com/j2se/1.4/docs/api/java/lang/String.html