title: which exception to throw when user tries to add to a full container
body: <p>I am trying to write a fixed sized queue for generic type elements.The user can call the constructor, providing a size and an internal array is created for that size.(see below)</p>
  
  <pre><code>class FixedSizeQ&lt;E&gt;{
      private E[] q;
      private int N;
  
      public FixedSizeQ(int max) {
          super();
          q = (E[]) new Object[max];
          N = 0;
      }
  ..
  }
  </code></pre>
  
  <p>I thought of defining an isEmpty() and isFull() methods and an insert() method for the above.If the client tries to add an element to the already full array,I want to throw an exception.Going through the javadocs,I thought <code>IllegalStateException</code> would be the correct exception to throw.</p>
  
  <pre><code>public boolean isFull(){
      return N == q.length;
  }
  public void insert(Item item){
      if(isFull()){
          throw new IllegalStateException("queue full");
      }
      ...     
  }
  </code></pre>
  
  <p>I want to know if my understanding is correct..Someone suggested that <code>IllegalArgumentException</code> is more appropriate.Can someone advise?</p>