public Bag(int size) {
        this.array = new Object[size];
        it = new Iterator<E>() {
            private int current;

            @Override
            public boolean hasNext() {
                return current < realCount && array[current] != null;
            }

            @Override
            @SuppressWarnings("unchecked")
            public E next() {
                checkRange();
                return (E) array[current++];
            }

            @Override
            public void remove() {
                throw new RuntimeException("不支持删除");
            }
        };
    }