java--charAt()

来源:互联网 发布:易语言2017盗号源码 编辑:程序博客网 时间:2024/05/19 02:40
public class TestString{    public static void main(String[] args)    {        int lowCount=0,hCount=0,oCount=0;               String S="alhjfweoihfHIFGIUE154355644164";        for(int i=0;i<S.length();i++)        {             char c=S.charAt(i);               if(c>='a'&&c<='z')             {                  lowCount++;             }else if(c>='A'&&c<='Z')             {                  hCount++;             }else              {                  oCount++;              }        }       System.out.println(lowCount+" "+hCount+" "+oCount);          }}

charAt(index) 返回指定索引处index的 char 值

原创粉丝点击