标签:lan utils com ted 重复 commons 结果 har log
计算一个字符串某个字符的出现次数
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,三次重复.
apache commons lang包中的StringUtils
标签:lan utils com ted 重复 commons 结果 har log
原文地址:http://www.cnblogs.com/ipetergo/p/6956410.html