This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
java_generics [2017/01/02 15:16] 178.237.8.52 [Unbound wildcards] |
java_generics [2017/01/02 15:17] (current) 178.237.8.52 [Upper-bound wildcards] |
||
---|---|---|---|
Line 63: | Line 63: | ||
Creates an instance of a ''List'' of **any kind**. An ''ArrayList'' of ''String>'' will be ok, for instance. | Creates an instance of a ''List'' of **any kind**. An ''ArrayList'' of ''String>'' will be ok, for instance. | ||
==== Upper-bound wildcards ==== | ==== Upper-bound wildcards ==== | ||
+ | |||
+ | Upper bound wildcards are used when you want to accept an **instance of a class or any of its derivatives** | ||
+ | |||
+ | <code java> | ||
+ | List<? extends Exception> list = new ArrayList<IOException>(); | ||
+ | </code> | ||
==== Lower-bound wildcards ==== | ==== Lower-bound wildcards ==== |