title: How does Lists.newArraylist() of Guava library work?
body: <p>I am trying to understand how <code>Lists.newArrayList()</code> knows the type of list to return.
  I saw the <a href="https://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/common/collect/Lists.java#79" rel="noreferrer">source code</a> for function <code>newArrayList()</code>, but it simply returns the <code>ArrayList</code> of generic type E.</p>
  
  <pre><code>public static &lt;E&gt; ArrayList&lt;E&gt; newArrayList() {
    return new ArrayList&lt;E&gt;();
  }
  </code></pre>
  
  <p>However, when I call the function, I don't pass any such information. </p>
  
  <pre><code>List&lt;String&gt; testList = Lists.newArrayList();
  </code></pre>
  
  <p>How does it know what type of <code>ArrayList</code> I want? </p>
  
  <p>I read about generics and <code>TypeToken</code> but could not relate to it through the code.</p>