public class AaNum {
public static void main(String[] args)
{
String s = new String("12HMa&%$k#d_34H3aH");
int max = 0;
int min = 0;
int other = 0;
for (int i = 0;i < s.length();i++)
{
if(s.charAt(i)>='A'&&s.charAt(i)<='Z')
{
max++;
}
else if(s.charAt(i)>='a'&&s.charAt(i)<='z')
{
min++;
}
else
other++;
}
System.out.println("max:"+max+"\nmin:"+min+"\nother:"+other);
max = 0;
min = 0;
other = 0;
for (int i = 0;i < s.length();i++)
{
if(Character.isUpperCase(s.charAt(i)) == true)
{
max++;
}
else if(Character.isLowerCase(s.charAt(i)) == true)
{
min++;
}
else
other++;
}
System.out.println("max:"+max+"\nmin:"+min+"\nother:"+other);
max = 0;
min = 0;
other = 0;
String sL = "abcdefghijklmnopqrstuvwxyz";
String sU = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (int i = 0;i < s.length();i++)
{
if(sL.indexOf(s.charAt(i)) != -1)
{
max++;
}
else if(sU.indexOf(s.charAt(i)) != -1)
{
min++;
}
else
other++;
}
System.out.println("max:"+max+"\nmin:"+min+"\nother:"+other);
}
 
}
 
//转载于清灵介质