单选题

下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是(  )。
public class FindKeyWords(
public static void main(sring[]args){
sting text=
"An array is a data structur that stores a eollection of"
+"values of the same type.You access each individu-
al value"
+"through an integer index.For example.if a is an
array"
+"of inergers,then all]is the ith integer in the ar-
ray.";
Int arrayCount=0;
Int idex=-l;
Sting arrarStr="array":
Index=text.indexof(arrayStr);
While(index 0){
++arrayCount:
Index+=arrayStr.1ength();
Index=text.indexof(arrayStr,index);
}
System.OUt.println
("the text contains"+arrayCount+"arrays");
}
}

发布于 2022-05-11 10:33:06

登录后免费查看答案
关注者
0
被浏览
6
知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看