首页 试题广场 > 试题详情
单选题

阅读下列Java代码,运行后正确的输出结果是( )。
public class Test {
public int coutStr(String[]arry,String str){
int count=0;
for(int i=0;i<arry.length;i++){
if(arry[i].indexOf(str)!=-1)
count++;
}
return count;
}
public static void main(String[] args) {
String[]arry={"happy","apple","money","ending"};
String findStr="a";
Test test=new Test();
int count=test.coutStr(arry,findStr);
System.out.println("此Java的数组中有"+count+"个字符串包含字符"+findStr);
}
}

  • A.此Java的数组中有1个字符串包含字符a
  • B.此Java的数组中有2个字符串包含字符a
  • C.编译错误
  • D.正常编译,运行时报错
提交并查看答案
下一题 上一题
Ke星伙伴们的回答/ 21个回答
关闭
关闭
QQ
交流群
邀请
好友
App
下载
意见
反馈
返回
顶部