title: Java Generics, Linked List
body: <p>I finished learning Generics and I didn't find it easy. However , I did understand it. Here is what I understood. I want you to correct me where I am wrong and answer a few questions :) .  </p>
  
  <pre><code>public class LinkedList&lt;T&gt; {
  //class definition
  }
  </code></pre>
  
  <p><li> This means that LinkedList&lt;> is a class that will accept objects of classes and also interfaces. </li></p>
  
  <pre><code>public class LinkedList&lt;T extends Object&gt; {
  //class definition
  }
  </code></pre>
  
  <p><li> This means that LinkedList&lt;> is a class that will accept objects of those classes <strong>only</strong> that extend Object class. Basically, all classes. In case of a raw type, T will be replaced by Object</li>  </p>
  
  <pre><code>public class LinkedList&lt;T extends Object &amp; java.lang.Serializable&gt; {
  //class definition
  }  
  </code></pre>
  
  <p><li> This means that LinkedList&lt;> is a class that accepts objects of <strong>all</strong> those classes that implement Serializable interface. If an object of user defined class has to be included in the list then the user defined class <strong>must</strong> implement Serializable.</li>  </p>
  
  <pre><code>public class LinkedList&lt;T&gt; implements Iterable&lt;T&gt; {
  //class definition
  }  
  </code></pre>
  
  <p><li> This means that the LinkedList&lt;> class can be used with a collection-based for loop. It must overload iterator() method and should have an inner class that implements <code>Itarator&lt;T&gt;</code> and overloads hasNext(), next() and remove()  </li><br>
  <em>Questions</em><br>
  1. Please explain the meaning of this in simple words and with an example, if possible:<br>
      public class <code>BinaryTree&lt;T extends Comparable&lt;? super T&gt;&gt;</code>  what replaces the ?
  2. I want to write the above mentioned LinkedList&lt;> class to a file using the writeObject() method. so I declare it as  </p>
  
  <pre><code>public class LinkedList&lt;T extends Object&gt; implements Serializable {
       //methods and data members      
  private class Node implements Serializable { //inner class
                    T object;
                    Node next;
             }
      }
  </code></pre>
  
  <p>Does the inner class have to implement Serializable as well?  </p>