title: Java generic class and SortedSet<of generic class>
body: <p>First of all, this is a homework exercise where I don't get what statement refers exactly to, maybe this is why is the only undone exercise.</p>
  
  <p>I have to create one generic class with a single attribute - totalNumberOfItems with methods which enables the user to set and return an entry.</p>
  
  <p>In main(), I have to create a <code>SortedSet&lt;of my generic class&gt;</code> variable which maintains all the items.</p>
  
  <p>I need to use add/addAll, return specific item or check if one item exist in my set.</p>
  
  <pre><code>SortedSet&lt;VirtualLibrary&gt; myLibrary = new TreeSet&lt;VirtualLibrary&gt;();
      //String Book(author, String title, int numberOfPages, int year, String genre)
      myLibrary.add(new Book("Author", "title", 300, 1930, "genre"));
  </code></pre>
  
  <p>This is my code in main, Book is a separated class which extends an item / entry class which my generic class extends.</p>
  
  <pre><code>public class VirtualLibrary&lt;T extends Entry&gt; {
  int totalNumberOfEntries = 0;
  </code></pre>
  
  <p>and I tried to @Override add method like this:</p>
  
  <pre><code>@Override
  void add(T object) {
      totalNumberOfEntries++;
  }
  </code></pre>
  
  <p>The problem is the following: <code>add(VirtualLibrary) in type Set&lt;VirtualLibrary&gt; is not applicable for the argument Book</code> and also I could not Override add method in my generic class. </p>
  
  <p>How should this one look to be good? Should I create an interface instead of class?</p>