【发布时间】:2017-10-30 22:55:31
【问题描述】:
charAt 不起作用...它返回的是哈希码,而不是结构中某个部分的值。
例如:charAt(0) where is '1' 返回 49 而不是 1
我能做什么?!
【问题讨论】:
-
欢迎来到 Stack Overflow!请发布minimal reproducible example。不清楚你的代码是什么。
-
没错。它返回字符 '1',当被视为
int时,其值为 49。 -
您的代码正在将返回的值转换为 int... 将其转换回
char,您将看到1 -
方法定义为
char charAt(int index),返回类型为char,那你为什么要把它赋值给一个numeric变量,例如int???