java 性格比较

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7640278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 20:48:12  来源:igfitidea点击:

Character Comparison

java

提问by Vernah

I'm currently doing an online course, however it doesn't seem to enjoy this method: Character.isWhiteSpace(c)

我目前正在做一个在线课程,但它似乎并不喜欢这种方法: Character.isWhiteSpace(c)

What other methods are there that can answer the below question?

还有哪些方法可以回答以下问题?

Assume that cis a char variable has been declared and already given a value. Write an expression whose value is true if and only if xis what is called a whitespace character (that is a space or a tab or a newline-- none of which result in ink being printed on paper).

假设c已经声明了一个 char 变量并且已经给定了一个值。编写一个表达式,其值为真当且仅当x是所谓的空白字符(即空格、制表符或换行符——它们都不会导致墨水打印在纸上)。

回答by Jon Newmuis

The Character class has the function Character.isWhitespace(char). See the Javadocfor more details.

Character 类具有功能Character.isWhitespace(char)。有关更多详细信息,请参阅Javadoc

回答by Bohemian

There is a java API for this: Character.isWhiteSpace(c)

有一个Java API: Character.isWhiteSpace(c)

回答by ratchet freak

if you don't want to/can't use libraries

如果您不想/不能使用库

c==' '||c=='\t'||c=='\n'||c=='\r'

note that \ris a carriage return it's part of the windows \r\ncombination (and used commonly in network protocols)

请注意,这\r是一个回车,它是 windows\r\n组合的一部分(并且通常用于网络协议)