I'm unsure of the significance of the number when initializing a byte array: e.g. byte[] t = new byte[2].
I've seen online that arrays are a fixed size so no matter what, the length of t should be 2 right?
Well then how come in this example:
byte[] t = new byte[0];
t = "hello".getBytes(StandardCharsets.ISO_8859_1);
System.out.println(t.length);
the output is 5? It seems like t is just getting filled with all the elements without caring about size.
I need something like this, where I append values to a byte array repeatedly, without knowing how big the array will end up, can I just keep adding to something like t here?
t?tno longer refers to your array. Instead, it now refers to the array returned bygetBytes.