title: Understanding bounded generics in java. What is the point?
body: <p>I am trying to understand bounded types and not quite grasping the point of them.</p>
  
  <p>There is an <a href="https://docs.oracle.com/javase/tutorial/java/generics/bounded.html" rel="nofollow noreferrer">example</a> of bounded generics on which  provides this use case:</p>
  
  <pre><code>public class NaturalNumber&lt;T extends Integer&gt; {
  
      private T n;
  
      public NaturalNumber(T n)  { this.n = n; }
  
      public boolean isEven() {
          return n.intValue() % 2 == 0;
      }
  
      // ...
  }
  </code></pre>
  
  <p>If you are going to restrict the classes that can be the parameterized type, why not just forget the parameterization all together and have:</p>
  
  <pre><code>public class NaturalNumber {
  
      private Integer n;
  
      public NaturalNumber(Integer n)  { this.n = n; }
  
      public boolean isEven() {
          return n.intValue() % 2 == 0;
      }
  
      // ...
  }
  </code></pre>
  
  <p>Then any class that extends/implements <code>Integer</code> can be used with this class.</p>
  
  <p>Also, a side question: How is <code>T</code> extending <code>Integer</code> in the first example when the Java <code>Integer</code> class is final?</p>