写出下面程序的输出结果 publicclassTestjava{ publicstaticvoidmain(String[]args){ Stringstr="abbaefabbewbvwabbswgfga"; System.out.println("count="+getSubCount(str,"abb")); } publicstaticintgetSubCount(Stringstr,Stringkey){ intcount=0; intindex=0; while((index=str.indexOf(key,index))!=-1){ System.out.println("index="+index); index=index+key.length(); count++; } returncount; } }
写出下面程序的输出结果 publicclassTestjava{ publicstaticvoidmain(String[]args){ Stringstr="abbaefabbewbvwabbswgfga"; System.out.println("count="+getSubCount(str,"abb")); } publicstaticintgetSubCount(Stringstr,Stringkey){ intcount=0; intindex=0; while((index=str.indexOf(key,index))!=-1){ System.out.println("index="+index); index=index+key.length(); count++; } returncount; } }
1