問題描述
我正在嘗試使用char方法isLetter()
,它應該返回對應于字符是否為字母的布爾值.但是當我調用該方法時,我收到一條錯誤消息,指出無法取消引用 char".我不知道取消引用 char 意味著什么或如何修復錯誤.有問題的陳述是:
I'm trying to use the char method isLetter()
, which is supposed to return boolean value corresponding to whether the character is a letter. But when I call the method, I get an error stating that "char cannot be dereferenced." I don't know what it means to dereference a char or how to fix the error. the statement in question is:
if (ch.isLetter())
{
....
....
}
有什么幫助嗎?取消引用 char 是什么意思?如何避免這樣做?
Any help? What does it mean to dereference a char and how do I avoid doing so?
推薦答案
char 類型是原始類型——不是對象——所以它不能被取消引用
The type char is a primitive -- not an object -- so it cannot be dereferenced
取消引用是訪問引用所引用的值的過程.由于 char 已經是一個值(不是引用),它不能被取消引用.
Dereferencing is the process of accessing the value referred to by a reference. Since a char is already a value (not a reference), it can not be dereferenced.
使用Character
類:
if(Character.isLetter(c)) {
這篇關于“Char 不能被取消引用"錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!