title: Java weird generic return type
body: <p>Browsing through <a href="http://guava-libraries.googlecode.com/svn/trunk/javadoc/index.html" rel="nofollow noreferrer">Guava</a> libraries I saw this weird signature on a readLines method from Files class:</p>
  
  <pre><code>public static &lt;T&gt; T readLines(File file,
                            Charset charset,
                            LineProcessor&lt;T&gt; callback)
  </code></pre>
  
  <p>I know a little bit about generics in java, but this baffled me. </p>
  
  <p>What does the double T mean here? And why is the first one in angled brackets?</p>
  
  <p><strong>UPDATE</strong>: Thanks for the answers. I am still not clear as to why I should use a T inside the brackets. Why for example can't it just be:</p>
  
  <pre><code> public static &lt;&gt; T readLines()
  </code></pre>
  
  <p>or</p>
  
  <pre><code> pulibc static &lt;K&gt; T readLines()
  </code></pre>
  
  <p>Or does the java syntax dictate that the SAME letter must be used?</p>
  
  <p>Now <a href="http://java.sun.com/docs/books/tutorial/extra/generics/methods.html" rel="nofollow noreferrer">this</a> is even wierder:</p>
  
  <pre><code>static &lt;T&gt; void fromArrayToCollection(T[] a, Collection&lt;T&gt; c) {
  </code></pre>
  
  <p>how can a method have a generic-return type and be void?</p>