A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

大国

初级黑马

  • 黑马币:0

  • 帖子:26

  • 精华:0

© 大国 初级黑马   /  2013-8-28 23:21  /  750 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

public class damo2 {
   public static void sop(String str)
   {  
            System.out.println(str);
   }
       
        public static void main(String[] args) {
        String str="abjggsorggojopggoj[kgg";
        sop(get(str,"gg"));    //这里怎么 出错了

       
        }
        public static int get(String str ,String key)
        { int come=0;
          int index=0;
                while((index=str.indexOf(key,index))!=-1)
                {
                        index=index+key.length();
                        come++;
                }return come;
        }

}


0 个回复

您需要登录后才可以回帖 登录 | 加入黑马