编写java 程序
定义一个长度为5的字符串数组,并初始化其初值为“open”, “door”, “the”, “open”, “name”;计算该数组中 “open”出现的次数,并倒序输出数组元素。
急求,如补充。。。。定义一个长度为5的字符串数组
答案:1 悬赏:40
解决时间 2021-03-08 14:26
- 提问者网友:敏感魔鬼
- 2021-03-08 02:58
最佳答案
- 二级知识专家网友:年轻没有失败
- 2021-03-08 04:05
public static void main(String[] args) {
String[] arr=new String[]{"open", "door", "the", "open", "name"};
int count=0;
for (int i = arr.length-1; i>=0; i--) {
if ("open".equals(arr[i])) {
count++;
}
System.out.println(arr[i]);
}
System.out.println("open次数为"+count);
}
String[] arr=new String[]{"open", "door", "the", "open", "name"};
int count=0;
for (int i = arr.length-1; i>=0; i--) {
if ("open".equals(arr[i])) {
count++;
}
System.out.println(arr[i]);
}
System.out.println("open次数为"+count);
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |