zoukankan      html  css  js  c++  java
  • Java Character 类

    Character 类用于对单个字符进行操作.

    Character 方法

    --------------------------------------------------------------------------

    Java isLetter() 方法  isLetter() 方法用于判断指定字符是否为字母

    例子:boolean isLetter(char ch) ch -- 要测试的字符 如果字符为字母,则返回 true;否则返回 false

    ---------------------------------------------------------------------------------------

    isDigit() 方法用于判断指定字符是否为数字。

    例子:public static boolean isDigit(char ch)  ch -- 要测试的字符。 如果字符为数字,则返回 true;否则返回 false
    ------------------------------------------------------------
    public class TestString {
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String str = scanner.nextLine();
    char[] chars = str.toCharArray();
    int length = chars.length;
    System.out.println("length:"+length);
    if(length>0){
    System.out.println("该字符串"+str+"中的数字是:");
    for (int i = 0; i <chars.length; i++) {
    char aChar = chars[i];
    if(aChar!=' '){
    if (Character.isDigit(aChar)){
    System.out.print(aChar+",");
    }
    }
    }
    }
    }
    }
    --------------------------------------------------
    3dee4r4f 4ffd2s6g70b
    length:21
    该字符串3dee4r4f 4ffd2s6g70b中的数字是:3,4,4,4,2,6,7,0,
     
  • 相关阅读:
    bat过滤任意字符
    汇编代码之修改文件时间
    使用C语言编写提取通用shellcode的程序
    汇编代码之修改文件时间
    VC++6.0中内存泄漏检测
    透视木马程序开发技术
    bat过滤任意字符
    VC++6.0中内存泄漏检测
    透视木马程序开发技术
    使用C语言编写提取通用shellcode的程序
  • 原文地址:https://www.cnblogs.com/2016-cxp/p/10922057.html
Copyright © 2011-2022 走看看