https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=Wildcard_%28Java%29 Wildcard (Java) - Versionsgeschichte 2025-05-24T07:05:59Z Versionsgeschichte dieser Seite in Wikipedia MediaWiki 1.45.0-wmf.2 https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=190607601&oldid=prev 93.224.98.64: /* Kovarianz für generische Typen */ Grammatik 2019-07-21T09:00:12Z <p><span class="autocomment">Kovarianz für generische Typen: </span> Grammatik</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 21. Juli 2019, 11:00 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 4:</td> <td colspan="2" class="diff-lineno">Zeile 4:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;syntaxhighlight lang="java" inline&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/syntaxhighlight&gt; meldet der Compiler bei beiden [[Typumwandlung|Konvertierungen]] (castings) &lt;syntaxhighlight lang="java" inline&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/syntaxhighlight&gt; und &lt;syntaxhighlight lang="java" inline&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/syntaxhighlight&gt; einen Fehler.</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;syntaxhighlight lang="java" inline&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/syntaxhighlight&gt; meldet der Compiler bei beiden [[Typumwandlung|Konvertierungen]] (castings) &lt;syntaxhighlight lang="java" inline&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/syntaxhighlight&gt; und &lt;syntaxhighlight lang="java" inline&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/syntaxhighlight&gt; einen Fehler.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit der Wildcard aufgeweicht werden, wenn &lt;syntaxhighlight lang="java" inline&gt;?&lt;/syntaxhighlight&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;syntaxhighlight lang="java" inline&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; ist der <del style="font-weight: bold; text-decoration: none;">abstrakter</del> Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer solchen Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;syntaxhighlight lang="java" inline&gt;Generisch&lt;/syntaxhighlight&gt; passen.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit der Wildcard aufgeweicht werden, wenn &lt;syntaxhighlight lang="java" inline&gt;?&lt;/syntaxhighlight&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;syntaxhighlight lang="java" inline&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; ist der <ins style="font-weight: bold; text-decoration: none;">abstrakte</ins> Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer solchen Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;syntaxhighlight lang="java" inline&gt;Generisch&lt;/syntaxhighlight&gt; passen.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Wildcard als Parametertyp ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Wildcard als Parametertyp ==</div></td> </tr> </table> 93.224.98.64 https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=144094968&oldid=prev PerfektesChaos: tk k 2015-07-16T21:45:03Z <p>tk k</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 16. Juli 2015, 23:45 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 1:</td> <td colspan="2" class="diff-lineno">Zeile 1:</td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Die '''Wildcard''' (selten auch '''Joker''') &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;?&lt;/syntaxhighlight&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung [[Generische Programmierung in Java|generischer (parametrisierter) Typen]].&lt;ref&gt;{{Internetquelle | url=http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.5.1 | titel=Chapter 4. Types, Values, and Variables | titelerg=4.5.1. Type Arguments and Wildcards | autor=James Gosling u.&amp;nbsp;a. | werk=Java Language Specification | datum=2013-02-28 | zugriff=2013-01-14 | sprache=<del style="font-weight: bold; text-decoration: none;">englisch </del>}}&lt;/ref&gt; In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Die '''Wildcard''' (selten auch '''Joker''') &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;?&lt;/syntaxhighlight&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung [[Generische Programmierung in Java|generischer (parametrisierter) Typen]].&lt;ref&gt;{{Internetquelle | url=http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.5.1 | titel=Chapter 4. Types, Values, and Variables | titelerg=4.5.1. Type Arguments and Wildcards | autor=James Gosling u.&amp;nbsp;a. | werk=Java Language Specification | datum=2013-02-28 | zugriff=2013-01-14 | sprache=<ins style="font-weight: bold; text-decoration: none;">en</ins>}}&lt;/ref&gt; In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/syntaxhighlight&gt; meldet der Compiler bei beiden [[Typumwandlung|Konvertierungen]] (castings) &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/syntaxhighlight&gt; und &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/syntaxhighlight&gt; einen Fehler.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/syntaxhighlight&gt; meldet der Compiler bei beiden [[Typumwandlung|Konvertierungen]] (castings) &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/syntaxhighlight&gt; und &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/syntaxhighlight&gt; einen Fehler.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit der Wildcard aufgeweicht werden, wenn &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;?&lt;/syntaxhighlight&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; ist der abstrakter Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer solchen Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Generisch&lt;/syntaxhighlight&gt; passen.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit der Wildcard aufgeweicht werden, wenn &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;?&lt;/syntaxhighlight&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; ist der abstrakter Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer solchen Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Generisch&lt;/syntaxhighlight&gt; passen.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Wildcard als Parametertyp ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Wildcard als Parametertyp ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Im Rumpf der generischen Einheit wird der Typparameter wie die obere Schranke (wenn uneingeschränkt, dann wie &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Object&lt;/syntaxhighlight&gt;) gehandhabt. Wenn der Ergebnistyp (return type) einer Funktion der Typparameter ist, kann das Ergebnis (z.B. vom Typ &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;?&lt;/syntaxhighlight&gt;) in eine Referenz vom Typ der Schranke (&lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Object&lt;/syntaxhighlight&gt;, wenn keine Schranke) übernommen werden. In die andere Richtung, zum Wildcard-Typ passt kein anderer Typ, nicht einmal &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Object&lt;/syntaxhighlight&gt;: Wenn &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;?&lt;/syntaxhighlight&gt; für den Typ des formalen Parameters einer Methode eingesetzt wurde, können ihr keine aktuellen Parameter übergeben werden. Sie kann dann nur nach Konvertierung (casting) der Wildcard-Referenz aufgerufen werden:</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Im Rumpf der generischen Einheit wird der Typparameter wie die obere Schranke (wenn uneingeschränkt, dann wie &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Object&lt;/syntaxhighlight&gt;) gehandhabt. Wenn der Ergebnistyp (return type) einer Funktion der Typparameter ist, kann das Ergebnis (z.<ins style="font-weight: bold; text-decoration: none;">&amp;nbsp;</ins>B. vom Typ &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;?&lt;/syntaxhighlight&gt;) in eine Referenz vom Typ der Schranke (&lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Object&lt;/syntaxhighlight&gt;, wenn keine Schranke) übernommen werden. In die andere Richtung, zum Wildcard-Typ passt kein anderer Typ, nicht einmal &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Object&lt;/syntaxhighlight&gt;: Wenn &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;?&lt;/syntaxhighlight&gt; für den Typ des formalen Parameters einer Methode eingesetzt wurde, können ihr keine aktuellen Parameter übergeben werden. Sie kann dann nur nach Konvertierung (casting) der Wildcard-Referenz aufgerufen werden:</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 29:</td> <td colspan="2" class="diff-lineno">Zeile 29:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>In diese Referenz kann nun eine Instanz von &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Generisch&lt;/syntaxhighlight&gt; eingehängt werden, wo der aktuelle</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>In diese Referenz kann nun eine Instanz von &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Generisch&lt;/syntaxhighlight&gt; eingehängt werden, wo der aktuelle</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Typparameter ein Untertyp von &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;UntertypVonSchranke&lt;/syntaxhighlight&gt; ist. In eine Einschränkung von unten</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Typparameter ein Untertyp von &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;UntertypVonSchranke&lt;/syntaxhighlight&gt; ist. In eine Einschränkung von unten</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 36:</td> <td colspan="2" class="diff-lineno">Zeile 36:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>können Instanziierungen von &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Generisch&lt;/syntaxhighlight&gt; mit einem beliebigen Obertyp (z.&amp;nbsp;B. &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Schranke&lt;/syntaxhighlight&gt;) von &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;UntertypVonSchranke&lt;/syntaxhighlight&gt; eingehängt werden. Es ist also möglich, dass die zugelassenen Typen von zwei Seiten eingeschränkt werden: von oben durch die Klassenvereinbarung (&lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;extends Schranke&lt;/syntaxhighlight&gt;), von unten durch die Referenzvereinbarung (&lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;super UntertypVonSchranke&lt;/syntaxhighlight&gt;).</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>können Instanziierungen von &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Generisch&lt;/syntaxhighlight&gt; mit einem beliebigen Obertyp (z.&amp;nbsp;B. &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Schranke&lt;/syntaxhighlight&gt;) von &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;UntertypVonSchranke&lt;/syntaxhighlight&gt; eingehängt werden. Es ist also möglich, dass die zugelassenen Typen von zwei Seiten eingeschränkt werden: von oben durch die Klassenvereinbarung (&lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;extends Schranke&lt;/syntaxhighlight&gt;), von unten durch die Referenzvereinbarung (&lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;super UntertypVonSchranke&lt;/syntaxhighlight&gt;).</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Objekterzeugung mit Wildcard-Instanziierungen ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Objekterzeugung mit Wildcard-Instanziierungen ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Obwohl von Wildcard-Instanziierungen keine Objekte erzeugt werden können (&lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;new Generisch&lt;?&gt;()&lt;/syntaxhighlight&gt; ist also verboten, weil &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; abstrakt ist), können Array-Objekte nur von uneingeschränkten Wildcard-Instanziierungen (also von keinen anderen generischen Instanziierungen) erzeugt werden: &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;new Generisch&lt;?&gt;[20]&lt;/syntaxhighlight&gt; ist korrekt, während &lt;syntaxhighlight<del style="font-weight: bold; text-decoration: none;"> enclose="none"</del> lang="java"&gt;new Generisch&lt;Schranke&gt;[20]&lt;/syntaxhighlight&gt; verboten ist.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Obwohl von Wildcard-Instanziierungen keine Objekte erzeugt werden können (&lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;new Generisch&lt;?&gt;()&lt;/syntaxhighlight&gt; ist also verboten, weil &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; abstrakt ist), können Array-Objekte nur von uneingeschränkten Wildcard-Instanziierungen (also von keinen anderen generischen Instanziierungen) erzeugt werden: &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;new Generisch&lt;?&gt;[20]&lt;/syntaxhighlight&gt; ist korrekt, während &lt;syntaxhighlight lang="java"<ins style="font-weight: bold; text-decoration: none;"> inline</ins>&gt;new Generisch&lt;Schranke&gt;[20]&lt;/syntaxhighlight&gt; verboten ist.</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><br /></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_20_3_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_13_1_lhs"></a>== Einzelnachweise ==</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_20_4_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_13_2_lhs"></a>&lt;references/&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Literatur ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Literatur ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* The Java Language Specification, Third Edition <del style="font-weight: bold; text-decoration: none;">(</del>Sun<del style="font-weight: bold; text-decoration: none;">)</del>, ISBN 978-0-321-24678-3</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* <ins style="font-weight: bold; text-decoration: none;">''</ins>The Java Language Specification<ins style="font-weight: bold; text-decoration: none;">''</ins>, Third Edition<ins style="font-weight: bold; text-decoration: none;">.</ins> Sun, ISBN 978-0-321-24678-3</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_20_0_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_17_0_lhs"></a>* <del style="font-weight: bold; text-decoration: none;">Java Tutorials, Lesson Generics </del>http://download.oracle.com/javase/tutorial/java/generics/index.html</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== Weblinks ==</div></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_20_1_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_19_0_lhs"></a>* <del style="font-weight: bold; text-decoration: none;">Typkompatibilität in Java </del>http://public.beuth-hochschule.de/~solymosi/veroeff/typkompatibilitaet/Typkompatibilitaet.html#Joker</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_17_0_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_20_0_rhs"></a>* <ins style="font-weight: bold; text-decoration: none;">[</ins>http://download.oracle.com/javase/tutorial/java/generics/index.html<ins style="font-weight: bold; text-decoration: none;"> ''Generics''.] Java Tutorials</ins></div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_19_0_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_20_1_rhs"></a>* <ins style="font-weight: bold; text-decoration: none;">[</ins>http://public.beuth-hochschule.de/~solymosi/veroeff/typkompatibilitaet/Typkompatibilitaet.html#Joker<ins style="font-weight: bold; text-decoration: none;"> Typkompatibilität in Java]</ins></div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_13_1_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_20_3_rhs"></a>== Einzelnachweise ==</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_13_2_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_20_4_rhs"></a>&lt;references<ins style="font-weight: bold; text-decoration: none;"> </ins>/&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Kategorie:Java (Programmiersprache)]]</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Kategorie:Java (Programmiersprache)]]</div></td> </tr> </table> PerfektesChaos https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=139207947&oldid=prev JamesP: fixed typo 2015-02-25T16:27:53Z <p>fixed typo</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 25. Februar 2015, 18:27 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 4:</td> <td colspan="2" class="diff-lineno">Zeile 4:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;syntaxhighlight enclose="none" lang="java"&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/syntaxhighlight&gt; meldet der Compiler bei beiden [[Typumwandlung|Konvertierungen]] (castings) &lt;syntaxhighlight enclose="none" lang="java"&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/syntaxhighlight&gt; und &lt;syntaxhighlight enclose="none" lang="java"&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/syntaxhighlight&gt; einen Fehler.</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;syntaxhighlight enclose="none" lang="java"&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/syntaxhighlight&gt; meldet der Compiler bei beiden [[Typumwandlung|Konvertierungen]] (castings) &lt;syntaxhighlight enclose="none" lang="java"&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/syntaxhighlight&gt; und &lt;syntaxhighlight enclose="none" lang="java"&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/syntaxhighlight&gt; einen Fehler.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit der Wildcard aufgeweicht werden, wenn &lt;syntaxhighlight enclose="none" lang="java"&gt;?&lt;/syntaxhighlight&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;syntaxhighlight enclose="none" lang="java"&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; ist der abstrakter Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer <del style="font-weight: bold; text-decoration: none;">solcher</del> Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;syntaxhighlight enclose="none" lang="java"&gt;Generisch&lt;/syntaxhighlight&gt; passen.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit der Wildcard aufgeweicht werden, wenn &lt;syntaxhighlight enclose="none" lang="java"&gt;?&lt;/syntaxhighlight&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;syntaxhighlight enclose="none" lang="java"&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; ist der abstrakter Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer <ins style="font-weight: bold; text-decoration: none;">solchen</ins> Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;syntaxhighlight enclose="none" lang="java"&gt;Generisch&lt;/syntaxhighlight&gt; passen.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Wildcard als Parametertyp ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Wildcard als Parametertyp ==</div></td> </tr> </table> JamesP https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=126566341&oldid=prev Jpp: /* Einleitung */ Link auf Hauptartikel Generische Programmierung in Java 2014-01-17T13:22:08Z <p><span class="autocomment">Einleitung: </span> Link auf Hauptartikel <a href="/wiki/Generische_Programmierung_in_Java" title="Generische Programmierung in Java">Generische Programmierung in Java</a></p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 17. Januar 2014, 15:22 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 1:</td> <td colspan="2" class="diff-lineno">Zeile 1:</td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Die '''Wildcard''' (selten auch '''Joker''') &lt;syntaxhighlight enclose="none" lang="java"&gt;?&lt;/syntaxhighlight&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung generischer (parametrisierter) Typen.&lt;ref&gt;{{Internetquelle | url=http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.5.1 | titel=Chapter 4. Types, Values, and Variables | titelerg=4.5.1. Type Arguments and Wildcards | autor=James Gosling u.&amp;nbsp;a. | werk=Java Language Specification | datum=2013-02-28 | zugriff=2013-01-14 | sprache=englisch }}&lt;/ref&gt; In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Die '''Wildcard''' (selten auch '''Joker''') &lt;syntaxhighlight enclose="none" lang="java"&gt;?&lt;/syntaxhighlight&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung <ins style="font-weight: bold; text-decoration: none;">[[Generische Programmierung in Java|</ins>generischer (parametrisierter) Typen<ins style="font-weight: bold; text-decoration: none;">]]</ins>.&lt;ref&gt;{{Internetquelle | url=http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.5.1 | titel=Chapter 4. Types, Values, and Variables | titelerg=4.5.1. Type Arguments and Wildcards | autor=James Gosling u.&amp;nbsp;a. | werk=Java Language Specification | datum=2013-02-28 | zugriff=2013-01-14 | sprache=englisch }}&lt;/ref&gt; In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> </tr> </table> Jpp https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=126566309&oldid=prev Jpp: Einzelnachweis hinzugefügt 2014-01-17T13:20:49Z <p>Einzelnachweis hinzugefügt</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 17. Januar 2014, 15:20 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 1:</td> <td colspan="2" class="diff-lineno">Zeile 1:</td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Die '''Wildcard''' (selten auch '''Joker''') &lt;syntaxhighlight enclose="none" lang="java"&gt;?&lt;/syntaxhighlight&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung generischer (parametrisierter) Typen. In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Die '''Wildcard''' (selten auch '''Joker''') &lt;syntaxhighlight enclose="none" lang="java"&gt;?&lt;/syntaxhighlight&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung generischer (parametrisierter) Typen.<ins style="font-weight: bold; text-decoration: none;">&lt;ref&gt;{{Internetquelle | url=http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.5.1 | titel=Chapter 4. Types, Values, and Variables | titelerg=4.5.1. Type Arguments and Wildcards | autor=James Gosling u.&amp;nbsp;a. | werk=Java Language Specification | datum=2013-02-28 | zugriff=2013-01-14 | sprache=englisch }}&lt;/ref&gt;</ins> In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 41:</td> <td colspan="2" class="diff-lineno">Zeile 41:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Obwohl von Wildcard-Instanziierungen keine Objekte erzeugt werden können (&lt;syntaxhighlight enclose="none" lang="java"&gt;new Generisch&lt;?&gt;()&lt;/syntaxhighlight&gt; ist also verboten, weil &lt;syntaxhighlight enclose="none" lang="java"&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; abstrakt ist), können Array-Objekte nur von uneingeschränkten Wildcard-Instanziierungen (also von keinen anderen generischen Instanziierungen) erzeugt werden: &lt;syntaxhighlight enclose="none" lang="java"&gt;new Generisch&lt;?&gt;[20]&lt;/syntaxhighlight&gt; ist korrekt, während &lt;syntaxhighlight enclose="none" lang="java"&gt;new Generisch&lt;Schranke&gt;[20]&lt;/syntaxhighlight&gt; verboten ist.</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Obwohl von Wildcard-Instanziierungen keine Objekte erzeugt werden können (&lt;syntaxhighlight enclose="none" lang="java"&gt;new Generisch&lt;?&gt;()&lt;/syntaxhighlight&gt; ist also verboten, weil &lt;syntaxhighlight enclose="none" lang="java"&gt;Generisch&lt;?&gt;&lt;/syntaxhighlight&gt; abstrakt ist), können Array-Objekte nur von uneingeschränkten Wildcard-Instanziierungen (also von keinen anderen generischen Instanziierungen) erzeugt werden: &lt;syntaxhighlight enclose="none" lang="java"&gt;new Generisch&lt;?&gt;[20]&lt;/syntaxhighlight&gt; ist korrekt, während &lt;syntaxhighlight enclose="none" lang="java"&gt;new Generisch&lt;Schranke&gt;[20]&lt;/syntaxhighlight&gt; verboten ist.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== <del style="font-weight: bold; text-decoration: none;">Referenzen</del> ==</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== <ins style="font-weight: bold; text-decoration: none;">Einzelnachweise</ins> ==</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;references/&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== Literatur ==</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* The Java Language Specification, Third Edition (Sun), ISBN 978-0-321-24678-3</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* The Java Language Specification, Third Edition (Sun), ISBN 978-0-321-24678-3</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* Java Tutorials, Lesson Generics http://download.oracle.com/javase/tutorial/java/generics/index.html</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* Java Tutorials, Lesson Generics http://download.oracle.com/javase/tutorial/java/generics/index.html</div></td> </tr> </table> Jpp https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=126565998&oldid=prev Jpp: /* Einschränkung der Wildcard */ Fehler aus Code-Beispielen entfernt 2014-01-17T13:09:45Z <p><span class="autocomment">Einschränkung der Wildcard: </span> Fehler aus Code-Beispielen entfernt</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 17. Januar 2014, 15:09 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 26:</td> <td colspan="2" class="diff-lineno">Zeile 26:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Generisch&lt;? <del style="font-weight: bold; text-decoration: none;">'''</del>extends<del style="font-weight: bold; text-decoration: none;">'''</del> UntertypVonSchranke&gt; vonObenEingeschränkteReferenz;</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Generisch&lt;? extends UntertypVonSchranke&gt; vonObenEingeschränkteReferenz;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 33:</td> <td colspan="2" class="diff-lineno">Zeile 33:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Generisch&lt;? <del style="font-weight: bold; text-decoration: none;">'''</del>super<del style="font-weight: bold; text-decoration: none;">'''</del> UntertypVonSchranke&gt; vonUntenEingeschränkteReferenz;</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Generisch&lt;? super UntertypVonSchranke&gt; vonUntenEingeschränkteReferenz;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> </table> Jpp https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=126565961&oldid=prev Jpp: Syntaxhighlights in Code-Beispielen 2014-01-17T13:08:37Z <p>Syntaxhighlights in Code-Beispielen</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 17. Januar 2014, 15:08 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 1:</td> <td colspan="2" class="diff-lineno">Zeile 1:</td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Die '''Wildcard''' (selten auch '''Joker''') &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;?&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung generischer (parametrisierter) Typen. In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Die '''Wildcard''' (selten auch '''Joker''') &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;?&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung generischer (parametrisierter) Typen. In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; meldet der Compiler bei beiden Konvertierungen (castings) &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; und &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; einen Fehler.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; meldet der Compiler bei beiden <ins style="font-weight: bold; text-decoration: none;">[[Typumwandlung|</ins>Konvertierungen<ins style="font-weight: bold; text-decoration: none;">]]</ins> (castings) &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; und &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; einen Fehler.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit der Wildcard aufgeweicht werden, wenn &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;?&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Generisch&lt;?&gt;&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; ist der abstrakter Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer solcher Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Generisch&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; passen.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit der Wildcard aufgeweicht werden, wenn &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;?&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Generisch&lt;?&gt;&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; ist der abstrakter Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer solcher Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Generisch&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; passen.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Wildcard als Parametertyp ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Wildcard als Parametertyp ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Im Rumpf der generischen Einheit wird der Typparameter wie die obere Schranke (wenn uneingeschränkt, dann wie &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Object&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt;) gehandhabt. Wenn der Ergebnistyp (return type) einer Funktion der Typparameter ist, kann das Ergebnis (z.B. vom Typ &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;?&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt;) in eine Referenz vom Typ der Schranke (&lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Object&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt;, wenn keine Schranke) übernommen werden. In die andere Richtung, zum Wildcard-Typ passt kein anderer Typ, nicht einmal &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Object&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt;: Wenn &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;?&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; für den Typ des formalen Parameters einer Methode eingesetzt wurde, können ihr keine aktuellen Parameter übergeben werden. Sie kann dann nur nach Konvertierung (casting) der Wildcard-Referenz aufgerufen werden:</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Im Rumpf der generischen Einheit wird der Typparameter wie die obere Schranke (wenn uneingeschränkt, dann wie &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Object&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt;) gehandhabt. Wenn der Ergebnistyp (return type) einer Funktion der Typparameter ist, kann das Ergebnis (z.B. vom Typ &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;?&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt;) in eine Referenz vom Typ der Schranke (&lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Object&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt;, wenn keine Schranke) übernommen werden. In die andere Richtung, zum Wildcard-Typ passt kein anderer Typ, nicht einmal &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Object&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt;: Wenn &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;?&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; für den Typ des formalen Parameters einer Methode eingesetzt wurde, können ihr keine aktuellen Parameter übergeben werden. Sie kann dann nur nach Konvertierung (casting) der Wildcard-Referenz aufgerufen werden:</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_9_1_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_7_2_rhs"></a>class Generisch&lt;T extends Schranke&gt; {</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_9_2_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_7_3_rhs"></a> <ins style="font-weight: bold; text-decoration: none;"> </ins>private T t;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_9_3_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_7_4_rhs"></a> <ins style="font-weight: bold; text-decoration: none;"> </ins>void schreiben(T t) { this.t = t; }</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_9_4_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_7_5_rhs"></a><ins style="font-weight: bold; text-decoration: none;"> </ins> T lesen() { return t; }</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>}</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_9_5_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_7_7_rhs"></a>...</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_9_6_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_7_8_rhs"></a>Generisch&lt;?&gt; jokerReferenz;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_9_7_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_7_9_rhs"></a>Schranke o = jokerReferenz.lesen(); // Object wäre auch OK</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_9_8_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_7_10_rhs"></a>jokerReferenz.schreiben(new Object()); // Typfehler</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_9_9_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_7_11_rhs"></a>((Generisch&lt;Schranke&gt;)jokerReferenz).schreiben(new Schranke()); // OK</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;code&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_7_2_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_9_1_lhs"></a><del style="font-weight: bold; text-decoration: none;"> '''</del>class<del style="font-weight: bold; text-decoration: none;">'''</del> Generisch&lt;T <del style="font-weight: bold; text-decoration: none;">'''</del>extends<del style="font-weight: bold; text-decoration: none;">'''</del> Schranke&gt; {</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_7_3_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_9_2_lhs"></a> <del style="font-weight: bold; text-decoration: none;">'''</del>private<del style="font-weight: bold; text-decoration: none;">'''</del> T t;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_7_4_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_9_3_lhs"></a> <del style="font-weight: bold; text-decoration: none;">'''</del>void<del style="font-weight: bold; text-decoration: none;">'''</del> schreiben(T t) { <del style="font-weight: bold; text-decoration: none;">'''</del>this<del style="font-weight: bold; text-decoration: none;">'''</del>.t = t; }</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_7_5_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_9_4_lhs"></a> T lesen() { <del style="font-weight: bold; text-decoration: none;">'''</del>return<del style="font-weight: bold; text-decoration: none;">'''</del> t;<del style="font-weight: bold; text-decoration: none;"> }</del> }</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_7_7_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_9_5_lhs"></a><del style="font-weight: bold; text-decoration: none;"> </del>...</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_7_8_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_9_6_lhs"></a><del style="font-weight: bold; text-decoration: none;"> </del>Generisch&lt;?&gt; jokerReferenz;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_7_9_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_9_7_lhs"></a><del style="font-weight: bold; text-decoration: none;"> </del>Schranke o = jokerReferenz.lesen(); // Object wäre auch OK</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_7_10_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_9_8_lhs"></a><del style="font-weight: bold; text-decoration: none;"> </del>jokerReferenz.schreiben(<del style="font-weight: bold; text-decoration: none;">'''</del>new<del style="font-weight: bold; text-decoration: none;">'''</del> Object()); // Typfehler</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_7_11_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_9_9_lhs"></a><del style="font-weight: bold; text-decoration: none;"> </del>((Generisch&lt;Schranke&gt;)jokerReferenz).schreiben(<del style="font-weight: bold; text-decoration: none;">'''</del>new<del style="font-weight: bold; text-decoration: none;">'''</del> Schranke()); // OK</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;/code&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Einschränkung der Wildcard ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Einschränkung der Wildcard ==</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Nicht nur der formale Typparameter, auch die Wildcard kann (weiter) von oben eingeschränkt werden, wenn man nicht beliebige Instanziierungen kompatibel halten möchte:</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Nicht nur der formale Typparameter, auch die Wildcard kann (weiter) von oben eingeschränkt werden, wenn man nicht beliebige Instanziierungen kompatibel halten möchte:</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;code&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Generisch&lt;? '''extends''' UntertypVonSchranke&gt; vonObenEingeschränkteReferenz;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Generisch&lt;? '''extends''' UntertypVonSchranke&gt; vonObenEingeschränkteReferenz;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;/code&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>In diese Referenz kann nun eine Instanz von &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Generisch&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; eingehängt werden, wo der aktuelle</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>In diese Referenz kann nun eine Instanz von &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Generisch&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; eingehängt werden, wo der aktuelle</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Typparameter ein Untertyp von &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;UntertypVonSchranke&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; ist. In eine Einschränkung von unten</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Typparameter ein Untertyp von &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;UntertypVonSchranke&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; ist. In eine Einschränkung von unten</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;syntaxhighlight lang="java"&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;code&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Generisch&lt;? '''super''' UntertypVonSchranke&gt; vonUntenEingeschränkteReferenz;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Generisch&lt;? '''super''' UntertypVonSchranke&gt; vonUntenEingeschränkteReferenz;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;/code&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>können Instanziierungen von &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Generisch&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; mit einem beliebigen Obertyp (z.B. &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Schranke&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt;) von &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;UntertypVonSchranke&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; eingehängt werden. Es ist also möglich, dass die zugelassenen Typen von zwei Seiten eingeschränkt werden: von oben durch die Klassenvereinbarung (&lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;<del style="font-weight: bold; text-decoration: none;">'''</del>extends<del style="font-weight: bold; text-decoration: none;">'''</del> Schranke&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt;), von unten durch die Referenzvereinbarung (&lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;<del style="font-weight: bold; text-decoration: none;">'''</del>super<del style="font-weight: bold; text-decoration: none;">'''</del> UntertypVonSchranke&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt;).</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>können Instanziierungen von &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Generisch&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; mit einem beliebigen Obertyp (z.<ins style="font-weight: bold; text-decoration: none;">&amp;nbsp;</ins>B. &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Schranke&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt;) von &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;UntertypVonSchranke&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; eingehängt werden. Es ist also möglich, dass die zugelassenen Typen von zwei Seiten eingeschränkt werden: von oben durch die Klassenvereinbarung (&lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;extends Schranke&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt;), von unten durch die Referenzvereinbarung (&lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;super UntertypVonSchranke&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt;).</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Objekterzeugung mit Wildcard-Instanziierungen ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Objekterzeugung mit Wildcard-Instanziierungen ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Obwohl von Wildcard-Instanziierungen keine Objekte erzeugt werden können (&lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;<del style="font-weight: bold; text-decoration: none;">'''</del>new<del style="font-weight: bold; text-decoration: none;">'''</del> Generisch&lt;?&gt;()&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; ist also verboten, weil &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;Generisch&lt;?&gt;&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; abstrakt ist), können Array-Objekte nur von uneingeschränkten Wildcard-Instanziierungen (also von keinen anderen generischen Instanziierungen) erzeugt werden: &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;<del style="font-weight: bold; text-decoration: none;">'''</del>new<del style="font-weight: bold; text-decoration: none;">'''</del> Generisch&lt;?&gt;[20]&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; ist korrekt, während &lt;<del style="font-weight: bold; text-decoration: none;">code</del>&gt;<del style="font-weight: bold; text-decoration: none;">'''</del>new<del style="font-weight: bold; text-decoration: none;">'''</del> Generisch&lt;Schranke&gt;[20]&lt;/<del style="font-weight: bold; text-decoration: none;">code</del>&gt; verboten ist.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Obwohl von Wildcard-Instanziierungen keine Objekte erzeugt werden können (&lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;new Generisch&lt;?&gt;()&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; ist also verboten, weil &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;Generisch&lt;?&gt;&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; abstrakt ist), können Array-Objekte nur von uneingeschränkten Wildcard-Instanziierungen (also von keinen anderen generischen Instanziierungen) erzeugt werden: &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;new Generisch&lt;?&gt;[20]&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; ist korrekt, während &lt;<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight enclose="none" lang="java"</ins>&gt;new Generisch&lt;Schranke&gt;[20]&lt;/<ins style="font-weight: bold; text-decoration: none;">syntaxhighlight</ins>&gt; verboten ist.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Referenzen ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Referenzen ==</div></td> </tr> </table> Jpp https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=126565222&oldid=prev Jpp: Joker -> Wildcard 2014-01-17T12:41:45Z <p>Joker -&gt; Wildcard</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 17. Januar 2014, 14:41 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 1:</td> <td colspan="2" class="diff-lineno">Zeile 1:</td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">Der</del> <del style="font-weight: bold; text-decoration: none;">Joker</del> (<del style="font-weight: bold; text-decoration: none;">oder</del> <del style="font-weight: bold; text-decoration: none;">[[Wildcard</del> <del style="font-weight: bold; text-decoration: none;">(Informatik)|Wildcard]]</del>) &lt;code&gt;?&lt;/code&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung generischer (parametrisierter) Typen. In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">Die</ins> <ins style="font-weight: bold; text-decoration: none;">'''Wildcard'''</ins> (<ins style="font-weight: bold; text-decoration: none;">selten</ins> <ins style="font-weight: bold; text-decoration: none;">auch</ins> <ins style="font-weight: bold; text-decoration: none;">'''Joker'''</ins>) &lt;code&gt;?&lt;/code&gt; ist in [[Java (Programmiersprache)|Java]] ein spezieller aktueller Typparameter für die Instanziierung generischer (parametrisierter) Typen. In diesem Artikel werden die wichtigsten Regeln für seine Verwendung zusammengefasst.</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Kovarianz für generische Typen ==</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;code&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/code&gt; meldet der Compiler bei beiden Konvertierungen (castings) &lt;code&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/code&gt; und &lt;code&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/code&gt; einen Fehler.</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Im Gegensatz zu [[Feld (Datentyp)|Arrays]] (die in Java [[Kovarianz und Kontravarianz|kovariant]] sind) sind unterschiedliche Instanziierungen eines generischen Typs untereinander nicht (auch nicht explizit) kompatibel: Nach den Vereinbarungen &lt;code&gt;Generisch&lt;Obertyp&gt; oberGenerisch; Generisch&lt;Untertyp&gt; unterGenerisch;&lt;/code&gt; meldet der Compiler bei beiden Konvertierungen (castings) &lt;code&gt;(Generisch&lt;Untertyp&gt;)oberGenerisch&lt;/code&gt; und &lt;code&gt;(Generisch&lt;Obertyp&gt;)unterGenerisch&lt;/code&gt; einen Fehler.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit <del style="font-weight: bold; text-decoration: none;">dem</del> <del style="font-weight: bold; text-decoration: none;">Joker</del> aufgeweicht werden, wenn &lt;code&gt;?&lt;/code&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;code&gt;Generisch&lt;?&gt;&lt;/code&gt; ist der abstrakter Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer solcher Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;code&gt;Generisch&lt;/code&gt; passen.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Diese Inkompatibilität kann mit <ins style="font-weight: bold; text-decoration: none;">der</ins> <ins style="font-weight: bold; text-decoration: none;">Wildcard</ins> aufgeweicht werden, wenn &lt;code&gt;?&lt;/code&gt; für einen aktuellen Typparameter eingesetzt wird: &lt;code&gt;Generisch&lt;?&gt;&lt;/code&gt; ist der abstrakter Obertyp aller Instanziierungen des generischen Typs. Das heißt, von diesem Typ können nur Referenzen, keine Objekte gebildet werden. Der Sinn einer solcher Referenz ist, dass zu ihr beliebige Instanziierungen von &lt;code&gt;Generisch&lt;/code&gt; passen.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== <del style="font-weight: bold; text-decoration: none;">Joker</del> als Parametertyp ==</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== <ins style="font-weight: bold; text-decoration: none;">Wildcard</ins> als Parametertyp ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Im Rumpf der generischen Einheit wird der Typparameter wie die obere Schranke (wenn uneingeschränkt, dann wie &lt;code&gt;Object&lt;/code&gt;) gehandhabt. Wenn der Ergebnistyp (return type) einer Funktion der Typparameter ist, kann das Ergebnis (z.B. vom Typ &lt;code&gt;?&lt;/code&gt;) in eine Referenz vom Typ der Schranke (&lt;code&gt;Object&lt;/code&gt;, wenn keine Schranke) übernommen werden. In die andere Richtung, zum <del style="font-weight: bold; text-decoration: none;">Joker</del>-Typ passt kein anderer Typ, nicht einmal &lt;code&gt;Object&lt;/code&gt;: Wenn &lt;code&gt;?&lt;/code&gt; für den Typ des formalen Parameters einer Methode eingesetzt wurde, können ihr keine aktuellen Parameter übergeben werden. Sie kann dann nur nach Konvertierung (casting) der <del style="font-weight: bold; text-decoration: none;">Joker</del>-Referenz aufgerufen werden:</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Im Rumpf der generischen Einheit wird der Typparameter wie die obere Schranke (wenn uneingeschränkt, dann wie &lt;code&gt;Object&lt;/code&gt;) gehandhabt. Wenn der Ergebnistyp (return type) einer Funktion der Typparameter ist, kann das Ergebnis (z.B. vom Typ &lt;code&gt;?&lt;/code&gt;) in eine Referenz vom Typ der Schranke (&lt;code&gt;Object&lt;/code&gt;, wenn keine Schranke) übernommen werden. In die andere Richtung, zum <ins style="font-weight: bold; text-decoration: none;">Wildcard</ins>-Typ passt kein anderer Typ, nicht einmal &lt;code&gt;Object&lt;/code&gt;: Wenn &lt;code&gt;?&lt;/code&gt; für den Typ des formalen Parameters einer Methode eingesetzt wurde, können ihr keine aktuellen Parameter übergeben werden. Sie kann dann nur nach Konvertierung (casting) der <ins style="font-weight: bold; text-decoration: none;">Wildcard</ins>-Referenz aufgerufen werden:</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;code&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;code&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 19:</td> <td colspan="2" class="diff-lineno">Zeile 20:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> ((Generisch&lt;Schranke&gt;)jokerReferenz).schreiben('''new''' Schranke()); // OK</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> ((Generisch&lt;Schranke&gt;)jokerReferenz).schreiben('''new''' Schranke()); // OK</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/code&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/code&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== Einschränkung <del style="font-weight: bold; text-decoration: none;">des</del> <del style="font-weight: bold; text-decoration: none;">Jokers</del> ==</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== Einschränkung <ins style="font-weight: bold; text-decoration: none;">der</ins> <ins style="font-weight: bold; text-decoration: none;">Wildcard</ins> ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Nicht nur der formale Typparameter, auch <del style="font-weight: bold; text-decoration: none;">der</del> <del style="font-weight: bold; text-decoration: none;">Joker</del> kann (weiter) von oben eingeschränkt werden, wenn man nicht beliebige Instanziierungen kompatibel halten möchte:</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Nicht nur der formale Typparameter, auch <ins style="font-weight: bold; text-decoration: none;">die</ins> <ins style="font-weight: bold; text-decoration: none;">Wildcard</ins> kann (weiter) von oben eingeschränkt werden, wenn man nicht beliebige Instanziierungen kompatibel halten möchte:</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;code&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;code&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 35:</td> <td colspan="2" class="diff-lineno">Zeile 36:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>können Instanziierungen von &lt;code&gt;Generisch&lt;/code&gt; mit einem beliebigen Obertyp (z.B. &lt;code&gt;Schranke&lt;/code&gt;) von &lt;code&gt;UntertypVonSchranke&lt;/code&gt; eingehängt werden. Es ist also möglich, dass die zugelassenen Typen von zwei Seiten eingeschränkt werden: von oben durch die Klassenvereinbarung (&lt;code&gt;'''extends''' Schranke&lt;/code&gt;), von unten durch die Referenzvereinbarung (&lt;code&gt;'''super''' UntertypVonSchranke&lt;/code&gt;).</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>können Instanziierungen von &lt;code&gt;Generisch&lt;/code&gt; mit einem beliebigen Obertyp (z.B. &lt;code&gt;Schranke&lt;/code&gt;) von &lt;code&gt;UntertypVonSchranke&lt;/code&gt; eingehängt werden. Es ist also möglich, dass die zugelassenen Typen von zwei Seiten eingeschränkt werden: von oben durch die Klassenvereinbarung (&lt;code&gt;'''extends''' Schranke&lt;/code&gt;), von unten durch die Referenzvereinbarung (&lt;code&gt;'''super''' UntertypVonSchranke&lt;/code&gt;).</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== Objekterzeugung mit <del style="font-weight: bold; text-decoration: none;">Joker</del>-Instanziierungen ==</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== Objekterzeugung mit <ins style="font-weight: bold; text-decoration: none;">Wildcard</ins>-Instanziierungen ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Obwohl von <del style="font-weight: bold; text-decoration: none;">Joker</del>-Instanziierungen keine Objekte erzeugt werden können (&lt;code&gt;'''new''' Generisch&lt;?&gt;()&lt;/code&gt; ist also verboten, weil &lt;code&gt;Generisch&lt;?&gt;&lt;/code&gt; abstrakt ist), können Array-Objekte nur von uneingeschränkten <del style="font-weight: bold; text-decoration: none;">Joker</del>-Instanziierungen (also von keinen anderen generischen Instanziierungen) erzeugt werden: &lt;code&gt;'''new''' Generisch&lt;?&gt;[20]&lt;/code&gt; ist korrekt, während &lt;code&gt;'''new''' Generisch&lt;Schranke&gt;[20]&lt;/code&gt; verboten ist.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Obwohl von <ins style="font-weight: bold; text-decoration: none;">Wildcard</ins>-Instanziierungen keine Objekte erzeugt werden können (&lt;code&gt;'''new''' Generisch&lt;?&gt;()&lt;/code&gt; ist also verboten, weil &lt;code&gt;Generisch&lt;?&gt;&lt;/code&gt; abstrakt ist), können Array-Objekte nur von uneingeschränkten <ins style="font-weight: bold; text-decoration: none;">Wildcard</ins>-Instanziierungen (also von keinen anderen generischen Instanziierungen) erzeugt werden: &lt;code&gt;'''new''' Generisch&lt;?&gt;[20]&lt;/code&gt; ist korrekt, während &lt;code&gt;'''new''' Generisch&lt;Schranke&gt;[20]&lt;/code&gt; verboten ist.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Referenzen ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Referenzen ==</div></td> </tr> </table> Jpp https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=126565128&oldid=prev Jpp: Jpp verschob die Seite Joker (Java) nach Wildcard (Java): Der Begriff "Joker" wird nur in einigen deutschsprachigen Publikationen verwendet, wesentlich verbreiteter ist der Begriff "Wildcard" 2014-01-17T12:38:33Z <p>Jpp verschob die Seite <a href="/wiki/Joker_(Java)" class="mw-redirect" title="Joker (Java)">Joker (Java)</a> nach <a href="/wiki/Wildcard_(Java)" title="Wildcard (Java)">Wildcard (Java)</a>: Der Begriff &quot;Joker&quot; wird nur in einigen deutschsprachigen Publikationen verwendet, wesentlich verbreiteter ist der Begriff &quot;Wildcard&quot;</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <tr class="diff-title" lang="de"> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Version vom 17. Januar 2014, 14:38 Uhr</td> </tr><tr><td colspan="2" class="diff-notice" lang="de"><div class="mw-diff-empty">(kein Unterschied)</div> </td></tr></table> Jpp https://de.wikipedia.org/w/index.php?title=Wildcard_(Java)&diff=116967097&oldid=prev KLBot2: Bot: 1 Interwiki-Link(s) nach Wikidata (:d:Q1702586) migriert 2013-04-04T07:29:46Z <p>Bot: 1 <a href="/wiki/Hilfe:Internationalisierung" title="Hilfe:Internationalisierung">Interwiki-Link(s)</a> nach <a href="/wiki/Wikipedia:Wikidata" title="Wikipedia:Wikidata">Wikidata</a> (<a href="https://www.wikidata.org/wiki/Q1702586" class="extiw" title="d:Q1702586">d:Q1702586</a>) migriert</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 4. April 2013, 09:29 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 44:</td> <td colspan="2" class="diff-lineno">Zeile 44:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Kategorie:Java (Programmiersprache)]]</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Kategorie:Java (Programmiersprache)]]</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><br /></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>[[en:Wildcard (Java)]]</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> </table> KLBot2