使用Character.getNumericValue()时出错(Error when using Character.getNumericValue())
我的代码是:
for(int i = 0; i < charArray.length; i++) { char charValue = Character.getNumericValue(charArray[i]);基本上,我试图检索我的char数组中每个项目的数值,但我在编译时收到此错误消息:
incompatible types: possible lossy conversion from int to char我很困惑,因为我没有处理整数。 我试图寻找解决我的具体问题的方法,但找不到答案。 提前感谢您提供的任何帮助。
My code reads:
for(int i = 0; i < charArray.length; i++) { char charValue = Character.getNumericValue(charArray[i]);Basically, I am trying to retrieve the numeric value of each item in my char Array, but I am receiving this error message when compiling:
incompatible types: possible lossy conversion from int to charI am confused because I am not dealing with ints. I tried searching for a resolution to my specific problem but could not find an answer. Thanks ahead of time for any help you provide.
最满意答案
当getNumerValue返回一个整数时,你输入的charValue变量是一个char。
将charValue类型设置为int并再次尝试。
you're typing the charValue variable is a char when getNumerValue returns an integer.
set charValue type to int and try again.
更多推荐
发布评论