Generics in the Java Programming Language (JDK)

JDK1.5 introduces several extensions to the Java programming Language.One of these
is the introduction of generics.
Thistutorialisaimedatintroducingyou to generics.Youmaybefamiliarwith
similarconstructs from other languages, mostnotablyC++templates.Ifso,you’llsoon
seethatthere are bothsimilaritiesandimportantdifferences.Ifyouarenotfamiliar
withlook-a-alikeconstructsfromelsewhere,allthebetter;youcanstartafresh,without
unlearninganymisconceptions.
Genericsallowyoutoabstractovertypes. The most commonexamplesarecon-
tainertypes,suchasthoseintheCollectionhierarchy.
Hereisatypicalusageofthatsor

Contents
1Introduction2
2De?ningSimpleGenerics3
3GenericsandSubtyping4
4Wildcards5
4.1BoundedWildcards………………………6
5GenericMethods7
6InteroperatingwithLegacyCode10
6.1UsingLegacyCodeinGenericCode………………10
6.2ErasureandTranslation…………………….12
6.3UsingGenericCodeinLegacyCode………………13
7TheFinePrint14
7.1AGenericClassisSharedbyallitsInvocations…………14
7.2CastsandInstanceOf……………………..14
7.3Arrays…………………………….15
8ClassLiteralsasRun-timeTypeTokens16
9MoreFunwithWildcards18
9.1WildcardCapture……………………….20
10ConvertingLegacyCodetoUseGenerics20
11Acknowledgements23

DOWNLOAD

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s