Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What we are having here is two different methods with individual type parameters each.</p> <pre><code>public abstract &lt;T extends AnotherClass&gt; void getAndParse(Args... args); </code></pre> <p>This is a method with a type parameter named T, and bounded by <code>AnotherClass</code>, meaning each subtype of <code>AnotherClass</code> is allowed as a type parameter.</p> <pre><code>public &lt;SpecificClass&gt; void getAndParse(Args... args) </code></pre> <p>This is a method with a type parameter named <code>SpecificClass</code>, bounded by <code>Object</code> (meaning each type is allowed as a type parameter). Do you really want this?</p> <p>Is the type parameter used inside <code>Args</code>? I think the problem would be there.</p> <hr> <p>Edit:</p> <p>The meaning of </p> <pre><code>public abstract &lt;T extends AnotherClass&gt; void getAndParse(T... args); </code></pre> <p>is that the <strong>caller</strong> of the method can decide with which type parameter he wants to call the method, as long as this is some subtype of <code>AnotherClass</code>. This means that in effect the method can be called with any objects of type <code>AnotherClass</code>.</p> <p>Since the caller can decide the type parameter, you can't in a subclass narrow down the parameter type to <code>SpecificClass</code> - this would not be an implementation of the method, but another method with same name (overloading).</p> <p>Maybe you want something like this:</p> <pre><code>public abstract class GetAndParse&lt;T extends AnotherClass&gt; { public SomeClass var; public abstract void getAndParse(T... args); } public class Implementor extends GetAndParse&lt;SpecificClass&gt; { // some field declarations // some method declarations @Override public void getAndParse(SpecificClass... args) { // method body making use of args } } </code></pre> <p>Now the <code>getAndParse</code> method implements the parent class' method.</p>
 

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