How does Collections.reverseOrder know what type parameter to use while returning Comparator<T>
<p>As per Java API spec, the signature of Collections.reverseOrder is</p>

<p><code>public static &lt;T&gt; Comparator&lt;T&gt; reverseOrder()</code></p>

<p>And the example given in the method description says it needs to be used as</p>

<p><code>Arrays.sort(a, Collections.reverseOrder());</code></p>

<p>When we call the method, nowhere do we specify what type to use (what T resolves to). </p>

<p>How does the compiler resolve T in this case? Can the return type (T) be resolved based on the type of the object it is being assigned to?</p>

<p>Btw, I'm aware of the overloaded <code>reverseOrder(Comparator&lt;T&gt; c)</code> method.</p>
