Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <code>&lt;?&gt;</code> syntax is java's way to specifying that the generic type is "unbounded" - ie it can be "anything". </p> <p><code>Enumeration&lt;?&gt;</code> is an Enumeration with an "unbounded type" - you can assign an Enumeration of any type to such a variable, for example:</p> <pre><code>Vector&lt;String&gt; v = new Vector&lt;String&gt;(); Enumeration&lt;String&gt; es = v.elements(); Enumeration&lt;?&gt; e = es; // This assignment compiles OK </code></pre> <p>However, being unbounded, the nextElement() method of an <code>Enumeration&lt;?&gt;</code> with return type <code>Object</code> (even if it's actually an <code>Enumeration&lt;String&gt;</code>), so you'll may have to cast:</p> <pre><code>String s = (String)e.nextElement(); // Unsafe cast - compiler warning </code></pre> <p><br/> For background, <a href="http://download.oracle.com/javase/6/docs/api/java/util/Enumeration.html" rel="nofollow">Enumeration</a> is a typed interface with two methods <a href="http://download.oracle.com/javase/6/docs/api/java/util/Enumeration.html#hasMoreElements%28%29" rel="nofollow">hasMoreElements()</a> and <a href="http://download.oracle.com/javase/6/docs/api/java/util/Enumeration.html#nextElement%28%29" rel="nofollow">nextElement()</a>. It was an early (poor) attempt that was superseded by <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Iterable.html" rel="nofollow">Iterable</a> and <a href="http://download.oracle.com/javase/6/docs/api/java/util/Iterator.html" rel="nofollow">Iterator</a>. A few old class use it, like <a href="http://download.oracle.com/javase/6/docs/api/java/util/Vector.html" rel="nofollow">Vector</a> and <a href="http://download.oracle.com/javase/6/docs/api/java/util/StringTokenizer.html" rel="nofollow">StringTokenizer</a>.</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