资源描述:
《Java语言程序设计与数据结构 基础篇原书第11版PPT及其他教辅资源20slide.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1Chapter20Lists,Stacks,Queues,andPriorityQueues2ObjectivesToexploretherelationshipbetweeninterfacesandclassesintheJavaCollectionsFrameworkhierarchy(§20.2).TousethecommonmethodsdefinedintheCollectioninterfaceforoperatingcollections(§20.2).TousetheIteratorinterfacetotraverseth
2、eelementsinacollection(§20.3).Touseafor-eachlooptotraversetheelementsinacollection(§20.3).ToexplorehowandwhentouseArrayListorLinkedListtostoreelements(§20.4).TocompareelementsusingtheComparableinterfaceandtheComparatorinterface(§20.5).TousethestaticutilitymethodsintheCollect
3、ionsclassforsorting,searching,shufflinglists,andfindingthelargestandsmallestelementincollections(§20.6).TodevelopamultiplebouncingballsapplicationusingArrayList(§20.7).TodistinguishbetweenVectorandArrayListandtousetheStackclassforcreatingstacks(§20.8).Toexploretherelationshi
4、psamongCollection,Queue,LinkedList,andPriorityQueueandtocreatepriorityqueuesusingthePriorityQueueclass(§20.9).Tousestackstowriteaprogramtoevaluateexpressions(§20.10).3WhatisDataStructure?Adatastructureisacollectionofdataorganizedinsomefashion.Thestructurenotonlystoresdata,bu
5、talsosupportsoperationsforaccessingandmanipulatingthedata.4JavaCollectionFrameworkhierarchyAcollectionisacontainerobjectthatholdsagroupofobjects,oftenreferredtoaselements.TheJavaCollectionsFrameworksupportsthreetypesofcollections,namedlists,sets,andmaps.5JavaCollectionFramew
6、orkhierarchy,cont.SetandListaresubinterfacesofCollection.6TheCollectionInterfaceTheCollectioninterfaceisformanipulatingacollectionofobjects.7TheListInterfaceAliststoreselementsinasequentialorder,andallowstheusertospecifywheretheelementisstored.Theusercanaccesstheelementsbyin
7、dex.8TheListInterface,cont.9TheListIterator10ArrayListandLinkedListTheArrayListclassandtheLinkedListclassareconcreteimplementationsoftheListinterface.Whichofthetwoclassesyouusedependsonyourspecificneeds.Ifyouneedtosupportrandomaccessthroughanindexwithoutinsertingorremovingel
8、ementsfromanyplaceotherthantheend,ArrayListoffersthemostefficientcollection