Javacollections•Acollectionallowsagroupofobjectstobetreatedasasingleunit.Arbitraryobjectscanbestored,retrievedandmanipulatedaselementsofthesecollections.•CollectionsFrameworkpresentsasetofstandardutilityclassestomanagesuchcollections.1.Itcontains‘coreinterfaces'whichallowcollectionstobemanipulatedindependentoftheirimplementations.Theseinterfacesdefinethecommonfunctionalityexhibitedbycollectionsandfacilitatedataexchangebetweencollections.2.Asmallsetofimplementationsthatareconcreteimplementationsofthecoreinterfaces,providingdatastructuresthataprogramcanuse.3.Anassortmentofalgorithmstoperformvariousoperationssuchas,sortingandsearching.•Collectionsframeworkisinterfacebased,collectionsareimplementedaccordingtotheirinterfacetype,ratherthanbyimplementationtypes.Byusingtheinterfaceswhenevercollectionsofobjectsneedtobehandled,interoperabilityandinterchangeabilityareachieved.•ByconventioneachofthecollectionimplementationclassesprovideaconstructortocreateacollectionbasedontheelementsintheCollectionobjectpassedasargument.Bythesametoken,MapimplementationsprovideaconstructorthatacceptsaMapargument.Thisallowstheimplementationofacollection(Collection/Map)tobechanged.ButCollectionsandMapsarenotinterchangeable.•InterfacesandtheirimplementationsinJava1.2Collection||__Set(nodupes,nullallowedbasedonimplementation)->HashSet||II__SortedSet(OrderedSet)->TreeSet|I__List(orderedcollection,dupesOK)->Vector,ArrayList,LinkedListMap(key-valuepairs,nullallowedbasedonimplementation)->HashTable,HashMapII__SortedMap(OrderedMap)->TreeMapInterfaceDescriptionCollectionAbasicinterfacethatdefinestheoperationsthatalltheclassesthatmaintaincollectionsofobjectstypicallyimplement.SetExtendsCollection,setsthatmaintainuniqueelements.SetinterfaceisdefinedintermsoftheequalsoperationSortedSetExtendsSet,maintaintheelementsinasortedorderListExtendsCollection,maintainelementsinasequentialorder,duplicatesallowed.MapAbasicinterfacethatdefinesoperationsthatclassesthatrepresentmappingsofkeystovaluestypicallyimplementSortedMapExtendsMapformapsthatmaintaintheirmappingsinkeyorder.•Classesthatimplementtheinterfacesusedifferentstoragemechanisms.1.ArraysIndexedaccessisfaster.Makesinsertion,deletionandgrowingthestoremoredifficult.2.LinkedListSupportsinsertion,deletionandgrowingthestore.Butindexedaccessisslower.3.TreeSupportsinsertion,deletionandgrowingthestore.Indexedaccessisslower.Butsearchingisfaster.4.HashingSupportsinsertion,deletionandgrowingthestore.Indexedaccessisslower.Butsearchingisfaster.However,requirestheuseofuniquekeysforstoringdataelements.DataStructuresInterfacesSetSortedSetListMapSortedMapHashTableHashSetHashMapHashTableResizableArrayArrayListVectorBalancedTreeTreeSetTreeMapLinkedListLinkedListSomeoftheoperationsinthecollectioninterfacesareoptional,meaningthattheimplementingclassmaychoosenottoprovideaproperimplementationofsuchanoperation.Insuchacase,anUnsupportedOperationExceptionisthrownwhenthatoperationisinvoked.InterfaceMethodsDescriptionCollectionBasicOperationsintsize();booleanisEmpty();booleancontains(Objectelement);booleanadd(Objectelement);booleanremove(Objectelement);Usedtoqueryacollectionaboutitscontents,andadd/removeelements.Theadd()andremove()methodsreturntrue讦thecollectionwasmodifiedasaresultoftheoperation.Thecontains()methodchecksformembership.BulkOperationsbooleancontainsAll(Collectionc);boole...