Java isWhitespace() 方法

Java 教程 · 2019-02-08 17:29:52

isWhitespace() 方法用于判断指定字符是否为空白字符,空白符包含:空格、tab键、换行符。

语法

boolean isWhitespace(char ch)

参数

  • ch -- 要测试的字符。

返回值

如果字符为空白字符,则返回 true;否则返回 false。

实例

public class Test {

    public static void main(String args[]) {
        System.out.println(Character.isWhitespace('c'));
        System.out.println(Character.isWhitespace(' '));
        System.out.println(Character.isWhitespace('\n'));
        System.out.println(Character.isWhitespace('\t'));
    }
}

以上程序执行结果为:

false
true
true
true

点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html

查看所有标签

Cascading Style Sheets 2.0 Programmer's Reference

Cascading Style Sheets 2.0 Programmer's Reference

Eric A. Meyer / McGraw-Hill Osborne Media / 2001-03-20 / USD 19.99

The most authoritative quick reference available for CSS programmers. This handy resource gives you programming essentials at your fingertips, including all the new tags and features in CSS 2.0. You'l......一起来看看 《Cascading Style Sheets 2.0 Programmer's Reference》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试