【发布时间】:2014-03-12 15:49:34
【问题描述】:
String str = "123456789";
byte[] bytes = str.getBytes();
我想做下面的循环
for (int j = 0; j < bytes.length(); j++) {
b = bytes[j];
}
b 将存储我数组的每个字节,但我似乎无法正确获取数组的长度。
Error:cannot find symbol
Problem solved: bytes.length instead of bytes.length()
【问题讨论】:
-
“似乎无法正确获取数组的长度”是什么意思?
-
为什么不呢?你得到什么错误?
-
Netbeans 显示错误“找不到符号”。
-
你认为为什么会这样?你收到错误了吗? (您应该使用
bytes.length而不是bytes.length()。) -
-1 不包括确切的编译器错误消息。