Why can't I use the wildcard (?) as type of parameter, field, local variable, or as return type of a method? : <p>The Oracle <a href="https://docs.oracle.com/javase/tutorial/java/generics/wildcards.html" rel="noreferrer">doc about Wildcards in generics</a> says,</p>

<blockquote>
  <p>The wildcard can be used in a variety of situations: as the <strong>type of a
  parameter</strong>, <strong>field</strong>, or <strong>local variable</strong>; sometimes as a <strong>return type</strong>
  (though it is better programming practice to be more specific).</p>
</blockquote>

<p>I have tried all four in the following class, and got compiler errors on each one. Why? What am I doing wrong?</p>

<pre><code>public class MainClass {
    private ? instanceFieldWithWildCardType;//ERROR
    private static ? staticFieldWithWildCardType;//ERROR

    private void methodWithWildCardParam(? param) {}//ERROR

    private void methodWithWildCardLocalVariable() {
        ? localVariableWithWildCardType;//ERROR
    }

    private ? methodWithWildCardReturnType() {//ERROR
        return null;
    }

    private void methodWithWildCardParam(? param) {}//ERROR

}
</code></pre>
