标题:请教关于字符串的,不知道怎么修改?
取消只看楼主
enenen
Rank: 1
等 级:新手上路
帖 子:11
专家分:4
注 册:2011-7-6
结帖率:100%
已结贴  问题点数:0 回复次数:1 
请教关于字符串的,不知道怎么修改?
使用循环嵌套进行串搜索操作。不使用indexof方法
public class StringTest {
    public int j,i;
    public  boolean isSubString(String s,String t)
    {
        for(i=0;i<=t.length();i++)
            for( j=0;j<=s.length();j++)
               
            {
                if(s.charAt(j) != t.charAt(i))
                    break;
                else
                {
                    i++;
                    if(j==s.length())
                        return true;
                    continue;
                }
               
            }
   
            return false;
        
        
    }
    public static void main(String[] args) {
      StringTest aaa=new StringTest();
        if(aaa.isSubString("hat", "The cat in the hat"))
            System.out.print("true");
        else
            System.out.print("false");
        
    }

}
搜索更多相关主题的帖子: continue public return 字符串 
2011-09-20 09:29
enenen
Rank: 1
等 级:新手上路
帖 子:11
专家分:4
注 册:2011-7-6
得分:0 
回复 2楼 husiwen
谢了
2011-09-20 16:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-350356-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014753 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved