Java Reference
In-Depth Information
However,youmightneedadifferentimplementationofoneoftheCollectionsFrame-
work core interfaces. If so, you can extend this framework by implementing the inter-
face,orbysubclassingoneofthemoreconvenient“ Abstract ”classes,suchas Ab-
stractQueue .
Youmightrequireacollectionthatisn'tsupportedbytheCollectionsFramework(or
perhaps you only think it isn't supported). For example, you might want to model a
sparsematrix,atablewheremanyormostofitselementsarezeros.Asparsematrixis
a good data structure for implementing a spreadsheet, for example.
Tomodelaspreadsheetorothersparsematrix,youcanworkwithnodes,whichare
objectsconsistingofvalueandlinkfields.Unlikeanarray,whereeachelementstoresa
singlevalueofthesameprimitivetypeorreferencesupertype,anodecanstoremultiple
valuesofdifferenttypes.Itcanalsostorereferencestoothernodes,whichareknownas
links.
Youcanconnectnodestogetherintolinkedlists,but(atleastforsinglylinkedlists)
thereisnoneedtodosobecauseyoucantakeadvantageoftheCollectionsFramework's
LinkedList class for this task. After all, you should not “reinvent the wheel.”
Broadlyspeaking,theCollectionsFrameworkisanexampleofautilityAPI. Chapter
6 continues to focus on utility APIs by introducing you to Java's concurrency utilities,
whichextendtheCollectionsFramework,the java.util.Objects class,andmore.
Search WWH ::




Custom Search