[java] How can we dynamically allocate and grow an array