title: How to implement a templated class that implements Collections
body: <p>This is a homework problem that I am having difficulty with. The skeleton for the class is given below:</p>
  
  <pre><code>public class Storage&lt;E&gt; implements java.util.Collection&lt;E&gt; {
  private Object[] data = new Object[256];
  private int nextEmptySlot = 0;
  
  @Override
  public java.util.Iterator&lt;E&gt; iterator() {
      // returns a class that iterates over the data array
      return new java.util.Iterator() {
          // insert the body of the inner class here
          // 3 methods: remove(), hasNext(), next()
          };
      }
  //Override all methods required by the interface
  }
  </code></pre>
  
  <p>Now the trouble I'm having is writing functions such as contains(Object o), because the template does not force E to be comparable. How can I treat the templated type E as comparable so that I can use equals and compateTo? I know there are ways to do it in the class declaration but the class declaration is given and does not require E to be comparable...</p>