zoukankan      html  css  js  c++  java
  • 计算某字符串中大写字母、小写字母以及数字的个数

    public class demo3 {
      public static void main(String[] args) {
        fun();
    }
      public static void fun() {
         String s = "asdklf2234jLKJ";
         byte [] s1=s.getBytes();
         int a=0,b=0,c=0;
         for (int i = 0; i < s1.length; i++) {
            
             if (s1[i]>=97 && s1[i]<=122) {
                a++;
            }
             if (s1[i]>=65&&s1[i]<=90) {
                b++;
            }
             if (s1[i]>=48&&s1[i]<=57) {
                c++;
            }
        }
         System.out.println("大写字母的个数为"+b);
         System.out.println("小写字母的个数为"+a);
         System.out.println("数字的个数为"+c);
    }
     
    }

  • 相关阅读:
    过河卒 题解
    You Are the One solution
    D
    Find a way solution
    A
    入门训练 Fibonacci数列
    求平均成绩 题解
    海选女主角 题解
    子集生成和组合问题
    log4j
  • 原文地址:https://www.cnblogs.com/lxy4/p/10554737.html
Copyright © 2011-2022 走看看