有个String的方法
String par;
String son;
……
int i = par.indexOf(str)就是str在par中的位置,如果没有匹配的,则i值为-1

解决方案 »

  1.   

    indexOf(String str) 
              Returns the index within this string of the first occurrence of the specified substring.for example:
    String s1="http://www.csdn.net/";
    String s2="csdn";
    int i=s1.indexOf(s2);
    System.out.println("index:"+i);
      

  2.   

    String的indexOf()和lastIndexOf()都可以用
      

  3.   

    不好意思,打错个地方
    int i = par.indexOf(son);
    i就是son字串在par字串中第一个匹配的位置