package com.company;
import java.sql.*;
public class Main
{
public static void main(String[] args) throws ClassNotFoundException, SQLException
{
System.out.println("请输入一个字符串:");
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
char[] ch = str.toCharArray();
char a1 = 'a';
while (a1<= 'z')
{
int n = 0;
for (int i = 0; i < ch.length; i++)
{
if (a1 == ch[i])
{
n++;
}
}
if(n!=0) System.out.println(a1+": "+n+"个");
a1++;
}
}
}
[Java练习]输入一个字符串,输出其中某个小写字母出现的次数
最新推荐文章于 2022-04-01 14:21:26 发布