Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>All of your <code>T</code>s are different, but you can only see it if you call your methods with the <a href="http://docs.oracle.com/javase/tutorial/java/generics/genmethods.html" rel="nofollow noreferrer">complete syntax</a>:</p> <p>For example, this code is valid:</p> <pre><code>new &lt;Float&gt;Rule&lt;Integer&gt;().&lt;Character&gt;Foo(); </code></pre> <p>Just to make this easier to explain, let's assume your code is this:</p> <pre><code>class Rule&lt;A&gt; { public &lt;B&gt;Rule() { } public &lt;C&gt; void Foo() { } } </code></pre> <p>Then you can explicitly declare generic types like:</p> <pre><code>new &lt;B&gt;Rule&lt;A&gt;().&lt;C&gt;Foo(); </code></pre> <p>If the types have the same name, the inner-most one will be chosen (the <code>T</code> on the method, not the class):</p> <p>With this code, taking parameters:</p> <pre><code>class Rule&lt;T&gt; { public &lt;T&gt;Rule(T t) { } public &lt;T&gt; void Foo(T t) { } } </code></pre> <p>Then this is valid:</p> <pre><code>new &lt;Float&gt;Rule&lt;Integer&gt;(3.2f); </code></pre> <p>Note that <code>T</code> in the constructor is <code>Float</code>, not <code>Integer</code>.</p> <p>Another example:</p> <pre><code>class Example&lt;T&gt; { public &lt;T&gt; void foo1() { // T here is the &lt;T&gt; declared on foo1 } public void foo2() { // T here is the &lt;T&gt; declared on the class Example } } </code></pre> <p>I found another question that deals with <a href="https://stackoverflow.com/questions/2050317/invoking-statically-imported-method-with-explicit-type-parameters">calling methods with explicit generic types without something before them</a>. It seems like static imports and same-class method calls are the same. It seems like Java doesn't let you start a line with <code>&lt;Type&gt;</code> for some reason.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload