[英]Why sometimes when I check whether a character is a digit by method isDigit in java, I get error?
If I have 如果我有
Character.isDigit('53')
I get error 我得到错误
but if I have: 但是如果我有:
Character.isDigit('5')
I get a boolean value of TRUE. 我得到布尔值TRUE。
Why is that so? 为什么会这样?
'5'
is a character. '5'
是一个字符。 '53'
is not a character. '53'
不是字符。
Or, to look at it in terms of strings, "5"
is a string with one character in it ( '5'
), and "53"
is a string with two characters in it ( '5'
, '3'
). 或者,从字符串的角度来看, "5"
是其中包含一个字符( '5'
)的字符串,而"53"
是其中具有两个字符( '5'
, '3'
)的字符串。
A character is a single symbol. 字符是单个符号。 This means that '5' is a character, but since '53' has two symbols, it is not a character. 这意味着“ 5”是一个字符,但是由于“ 53”具有两个符号,因此它不是一个字符。
“ 5”和“ 53”都表示为字符串,其中第一个包含一个字符,第二个包含两个字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.