title: Is there any reason to use generics in Java?
body: <p>Perhaps I'm missing the point but coming from a C# background, I can't see any reason to use Java's generics...</p>
  <p>In C# I've got a method which takes a string and deserializes it into an object...</p>
  <pre><code>public static Deserialize&lt;T&gt;(string source) {
      // Use reflection to examine T and determine
      // which properties I should be reading from
      // the string. Create an instance of T, 
      // populate the properties and return it
  }
  </code></pre>
  <p>which I can call as follows: <code>x.Deserialize&lt;AnyClass&gt;(&quot;String representation of AnyClass&quot;);</code></p>
  <p>Type erasure seems to make this impossible in Java?</p>
  <p>My next most common usage of generics is storing things in lists but since I can't do <code>List&lt;int&gt;</code> and have to box to use <code>List&lt;Integer&gt;</code>, it seems like pointless overhead boxing/unboxing when I could just use <code>int[]</code>.</p>
  <p>So... Is the only real use for generics to do things like</p>
  <pre><code>List&lt;MyClass&gt; MyClassList = new List&lt;MyClass&gt;
  </code></pre>
  <p>and get some compile-time type checking? If so, it seems pretty redundant given that the variable name makes it clear what the type should be (at least as long as I'm using sensible naming conventions).</p>
  <p>I can't help but feel I'm missing something...</p>