What I trying to do is creating an empty array such as
char[] array = {};
then I have a method called append
static void append(char array[], char x) {
array = Arrays.copyOf(array, array.length + 1);
array[array.length - 1] = x;
}
for example, I try to append x into the empty array and it keeps throwing Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0