@Test(expected = NoSuchElementException.class) public void tryToRemoveFromAnEmptyBag() { RandomizedBag<Integer> bag = new RandomizedBag<>(); bag.remove(); }
public E remove() { if (isEmpty()) { throw new NoSuchElementException("Cannot remove an element from an empty bag."); } return elems.remove(0); }
RandomizedBag extends AbstractCollection<E> implements Serializable { public E remove() { if (isEmpty()) { throw new NoSuchElementException("Cannot remove an element from an empty bag."); } return elems.remove(0); } }
RandomizedBag extends AbstractCollection<E> implements Serializable { public E remove() { if (isEmpty()) { throw new NoSuchElementException("Cannot remove an element from an empty bag."); } return elems.remove(0); } RandomizedBag();  RandomizedBag(long seed);  RandomizedBag(Collection<E> c);  RandomizedBag(long seed, Collection<E> c); }
RandomizedBag extends AbstractCollection<E> implements Serializable { public E remove() { if (isEmpty()) { throw new NoSuchElementException("Cannot remove an element from an empty bag."); } return elems.remove(0); } RandomizedBag();  RandomizedBag(long seed);  RandomizedBag(Collection<E> c);  RandomizedBag(long seed, Collection<E> c); @Override boolean add(E e); E remove(); Iterator<E> iterator(); @Override int size(); }
RandomizedBag extends AbstractCollection<E> implements Serializable { public E remove() { if (isEmpty()) { throw new NoSuchElementException("Cannot remove an element from an empty bag."); } return elems.remove(0); } RandomizedBag();  RandomizedBag(long seed);  RandomizedBag(Collection<E> c);  RandomizedBag(long seed, Collection<E> c); @Override boolean add(E e); E remove(); Iterator<E> iterator(); @Override int size();  }