第一题:public class Test3 { public static void main(String[] args) { String s = "abcdhelloeurtueorhdkabdfas"; String key = "wervhelloas"; int m=key.length(); int a=0; int count=0; while(s.length()>key.length()){ if(!s.contains(key)){ break; } a=s.indexOf(key); s=s.substring( a+key.length(),s.length()); count++; } System.out.println(count); } } |