private Object extendArray(Object array, int currentSize, int requiredSize) {
        if (requiredSize < currentSize) {
            return array;
        } else {
            Object newArray = null;
            int newSize = currentSize * 2;

            if (newSize <= requiredSize) {
                newSize = requiredSize + 1;
            }

            if (array instanceof char[]) {
                newArray = new char[newSize];
            } else if (array instanceof Object[]) {
                newArray = new Object[newSize];
            } else {
                throw new RuntimeException();
            }

            System.arraycopy(array, 0, newArray, 0, currentSize);
            return newArray;
        }
    }
Ensure the capacity of an array, allocating a new one if necessary.
Usually extends only for name hash collisions.
src/nu/validator/gnu/xml/aelfred2/XmlParser.java