public class java1213
{
 public static void main(String[] args)
 {
  String one="joy0626";
  String two="joy853";
  String three="goto";
  String fore="tenwa&joy";
  String str=new String();
  String str1=new String();
  String str2=new String();
  String str3=new String();
  String str4=new String();
  int i,j;
       //印出字串長度
  for (i=0;i<=200;i++)
      {
       str=one.substring(0,i);
            if (str==one)
            {
             System.out.println(i);
             break;
            }
      }

      //插入字串

      j=5;
       for (i=0;i<=j;i++)
           str1=two.substring(0,i);

       for (i=j;i<100;i++)
      {
       str2=two.substring(j,i);
            if ((str1+str2).equals(two))
               break;
      }
      str3=str1+three+str2;
      System.out.println(str3);

      //取代字串

  /*    j=5;
       for (i=0;i<=j;i++)
           str3=fore.substring(0,i);

       for (i=0;i<=100;i++)
      {
       str4=three.substring(j,i);
            if ((str3+str4).equals(two))
               break;
      }
      str3=str1+three+str2;
      System.out.println(str3);

  */


 }
}


arrow
arrow
    全站熱搜

    Joy 發表在 痞客邦 留言(0) 人氣()