The following snippet makes sense yet when I run this against my unit test.. I get a ClassCastException (Object can\'t be cast to String) on the line marked with \'>>>>\'.
I don't know what is this code for, but it puts burden to the garbage collector, since to add one element, you allocate a new array. You should use any implementation of List for this, for example, ArrayList.