黑马程序员技术交流社区
标题:
请统计和打印出字符串中包含中文字符、英文字符和数字字符的个数。
[打印本页]
作者:
段燚涛
时间:
2015-8-5 10:15
标题:
请统计和打印出字符串中包含中文字符、英文字符和数字字符的个数。
有一个字符串,其中包含中文字符、英文字符和数字字符,请统计和打印出
各个字符的个数。
作者:
段燚涛
时间:
2015-8-5 10:18
int engishCount;
int chineseCount;
int digitCount;
for(int i=0;i<str.length;i++)
{
charch = str.charAt(i);
if(ch>=’0’&& ch<=’9’)
{
digitCount++
}
elseif((ch>=’a’&& ch<=’z’) || (ch>=’A’ && ch<=’Z’))
{
engishCount++;
}
else
{
chineseCount++;
}
}
System.out.println(……………);
复制代码
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2