首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。 public class Fi ndKey Words{ public static void mai n(sri ng[]args){ sti ng text
下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。 public class Fi ndKey Words{ public static void mai n(sri ng[]args){ sti ng text
admin
2012-12-02
40
问题
下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。
public class Fi ndKey Words{
public static void mai n(sri ng[]args){
sti ng text =
"An array is a data structur that stores a collection of"
+"values of the same type .You access eachi ndividu-al value"
+"through an i nteger i ndex .For example ,if a is anarray"
+"of i nergers ,then a[i]is the ith i nteger i n the ar-ray .";
Int arrayCount =0;
Int idex =-1;
Sti ng arrarStr ="array";
Index =text .i ndexof(arrayStr);
While(i nde_________x 0){
++arrayCount ;
Index +=arrayStr .length();
Index =text .i ndexof(arrayStr ,i ndex);
}
Syste m.out .pri ntln
("the text contai ns"+arrayCount +"arrays");
}
}
选项
A、<
B、=
C、<=
D、>=
答案
D
解析
在字符串中查询指定的字符或子串,可用i ndexof()方法,如查询成功,返回所查字符的位置。如不成功,返回-1,从下面程序可以看出,While 条件应为查询成功。
转载请注明原文地址:https://jikaoti.com/ti/w5kiFFFM
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
在月球上可能发生的现象是()。
以下中国历史上著名历史事件按发生先后顺序排序,完全正确的是()。
毛泽东同志总结中国近代历次运动失败时曾说:“没有农民办不成大事,光有农民办不好大事。”下列事件属于“光有农民办不好大事”的是()。
行政机关公开政府信息的原则不包括()。
甲被宣告死亡后,其妻乙改嫁于丙,其后丙死亡。1年后乙确知甲仍然在世,遂向法院申请撤销对甲的死亡宣告。依我国法律,该死亡宣告撤销后,甲与乙原有的婚姻关系如何?()
甲贩运假烟,驾车路过某检查站时,被工商执法部门拦住检查。检查人员乙正登车检查时,甲突然发动汽车夺路而逃。乙抓住汽车车门的把手不放,甲为摆脱乙,在疾驶时突然急刹车,导致乙头部着地身亡。甲对乙死亡的心理态度属于下列哪一选项?()
下列选项中,英语是其国家或地区的官方语言之一的是()。
政府为了保护农业生产者,对部分农业产品规定了保护价格。为了采取这种价格政策,应采取的相应措施是()。
某区对用电的收费标准规定如下:每月每户用电不超过10度的部分,按每度0.45元收费;超过10度而不超过20度的部分,按每度0.80元收费;超过20度的部分,按每度1.50元收费。某月甲用户比乙用户多交电费7.10元,乙用户比丙用户多交3.75元,那么甲、乙
通过对海豚间通信联系的深入研究,科学家发现,齐普夫定律和信息论中的熵值概念可以很好地为分析外星信号服务。在接收到地外任何可疑信号后,应该首先用齐普夫定律分析是否存在一定斜率直线特征,如果有某种特征,则证明其并非毫无意义的噪声。然后进行熵值分析,这样可以不必
随机试题
A.补肺益气B.补肾纳气C.两者皆是D.两者皆非(1993年第117,118题)喘促口久,动则喘甚,呼多吸少,短气神疲,自汗畏风,形寒肢冷,舌质淡,苔黑润,脉沉弱。治法是()
具有抗氧化功能的水溶性维生素是
中医药信息涉及到下列哪些方面
索赔文件是承包商向业主索赔的正式书面材料,也是业主审议承包商索赔请求的主要依据。索赔文件不包括()
下列选项中可以引起税务代理关系变更的有()。
金融期货的买人方对是否履约具有选择的权利。()
下列关于海洋专属经济区的叙述,正确的是()。
A、 B、 C、 D、 BA、C、D中的梯形是必须翻转才能得到左图中的梯形,故本题选B。
简述清末修律的主要特点和历史意义。
设其中函数f,g具有二阶连续偏导数,求
最新回复
(
0
)