i have a male cat. the color of male cat is Black
现在我也不想将它拆分,所以我想搜索一个“雄猫”这个词.它在我的字符串中出现两次!
我在想的是:
int c = 0;
for (int j = 0; j < text.length(); j++) {
if (text.contains("male cat")) {
c += 1;
}
}
System.out.println("counter=" + c);
它给了我46计数值!那么解决方案是什么?
本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/java-jisuanzifuchuanzhongworddechuxiancishu.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 23, 2019 at 11:49 下午