zoukankan      html  css  js  c++  java
  • apache commons lang包中的StringUtils

    计算一个字符串某个字符的出现次数
    a, 使用charAt方法截取之后,循环判断.
    b, 使用apache commons lang包中的StringUtils:
    int n = StringUtils.countMatches("ababababab", "a");
    System.out.println(n);
    
    
    如何使一个字符串重复N次。
    API提供了一个非常好的方法。String str = "ab";
    String repeated = StringUtils.repeat(str,3);//输出的结果是ababab,三次重复.
    

      

  • 相关阅读:
    053403
    053402
    053401
    053400
    053399
    053398
    053397
    053396
    053395
    第k小数
  • 原文地址:https://www.cnblogs.com/ipetergo/p/6956410.html
Copyright © 2011-2022 走看看