As I understand it, if I want to create an empty array (to fill later during my program's runtime) I have to set its size, so that Java knows how much memory to allocate. So, if I create the following int array:
int[][] board = new int[3][3];
Java will allocate 3x3x4 bytes of RAM.
But if a String is an array of characters, how can Java predict how much RAM is needed without knowing how long my String will be? For example:
String[] nameList = new String[5]
The names I put in this array could be any amount of characters long. How is memory allocated in that case?