public static void main(String[] args) {
String str ="a1b2c3d4e5f6d7*ABCDf";
IntStream chars = str.chars();
int reduce = (int) chars.filter(Character::isLowerCase).count();
System.out.println(reduce);
}
Lambda表达式计算字符串中小写字母个数
最新推荐文章于 2023-10-10 20:31:42 发布
本文展示了一段Java代码,该代码使用IntStream和Character API来统计字符串中小写字母的数量。通过实例化一个字符串并利用chars方法将其转换为IntStream,然后通过filter方法筛选出所有的小写字母,并用count方法计算其总数。
2万+

被折叠的 条评论
为什么被折叠?



