String str = "123456789";
byte[] bytes = str.getBytes();
I want to make the following loop
for (int j = 0; j < bytes.length(); j++) {
b = bytes[j];
}
b
will store each byte of my array, but I can't seem to get the length of the array correctly.
Error:cannot find symbol
Problem solved: bytes.length instead of bytes.length()
Use bytes.length
without the ()
See the JLS - 10.7. Array Members:
The members of an array type are all of the following:
The
public final field length
, which contains the number of components of the array. length may be positive or zero.
length
is a property, not a method. You should write:
bytes.length
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With