我有一个看起来像的字符串:
"Hello my is Joeseph. It is very nice to meet you. What a wonderful day it is!".
我想计算is字符串中的次数。
is
如何用Java做到这一点?
int index = input.indexOf(“is”); int count = 0; while (index != -1) { count++; input = input.substring(index + 1); index = input.indexOf(“is”); } System.out.println(“No of is in the input is : ” + count);