public class DemoText {

    public static void main(String[] args) {
        
        fun1();
    }
    public static void fun1(){
            String s = "hello word Ok Yes hello hello";
            
            int sum=0;
            while(s.contains("lo")){
                
                sum++;
                s=s.replaceFirst("lo", "");
            }
            System.out.println("指定字符串在原字符中出現:"+sum+"次");
        }
}

相关文章:

  • 2021-12-28
  • 2021-07-21
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2020-04-30
  • 2022-12-23
  • 2021-09-09
  • 2022-01-28
  • 2022-01-13
  • 2022-12-23
相关资源
相似解决方案