公共靜態void main(String[] args) {
String content = "我有壹只狗,我愛狗,狗是我的朋友";
getDogNums(內容);
system . out . println(mNums);
}
靜態整數;
公共靜態void getDogNums(String str) {
int index = str . index of(" dog ");
如果(索引!= -1) {
mnums++;
getDogNums(str . substring(index+1));
}
}