Velocity Reviews

Velocity Reviews (
-   Java (
-   -   Re: generics (

Stefan Ram 04-29-2012 11:42 PM

Re: generics
Neil Morris <> writes:
>How can I stop a subtype from being passed to the 'add'

When a method has a parameter of type T, then an
expression of type U is acceptable as the corresponding
argument expression, whenever U is a subtype of T.

This cannot be changed.

To accept only expressions of type T as argument
expressions, T must be final.

To accept only objects of type T as argument values,
the parameter value must be checked using ».getClass«.

All times are GMT. The time now is 03:26 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.