subtype : Java Glossary


Starting with Java 1.5, When you have generics, List<String> (a List guaranteed to contain nothing but Strings) and List<?> (a List containing any sort of Object) are considered the same class, however, List<String> is a subtype of List<?> because every List<String> is also a List<?>. When you override a method, you have the option of returning an object of a subtype of the one returned by the method in the base class. In other words, you can narrow but not widen what the method can return.

This page is posted
on the web at:

Optional Replicator mirror
on local hard disk J:

Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.
no blog for this page
Your face IP:[]
You are visitor number