Java 数组中统计字母'A'的个数 - 代码示例
"Java 数组中统计字母'A'的个数 - 代码示例"\n\n本文介绍了如何使用Java循环遍历数组,统计字符数组中字母'A'出现的次数。附带代码示例和输出结果。\n\njava\nchar[] arr = {'A','1','R','!','e','&','A','5','A','g','#','D'};\nint count = 0;\nfor (int i = 0; i < arr.length; i++) {\n if (arr[i] == 'A') {\n count++;\n }\n}\nSystem.out.println(\"字母A的个数为:\" + count);\n\n\n输出结果为:字母A的个数为:3
原文地址: https://www.cveoy.top/t/topic/pZ3x 著作权归作者所有。请勿转载和采集!