140x Filetype PDF File size 0.15 MB Source: cs1331.gitlab.io
Introduction to Object-Oriented Programming Java Collections Christopher Simpkins chris.simpkins@gatech.edu CS1331 (Georgia Tech) Java Collections 1/ 12 TheCollections Framework Acollection is an object that represents a group of objects. Thecollections framework allows different kinds of collections to be dealt with in an implementation-independent manner. CS1331 (Georgia Tech) Java Collections 2/ 12 Collection Framework Components TheJavacollections framework consists of: Collection interfaces representing different types of collections (sets, lists, etc) General purpose implementations (like ArrayList or HashSet) Absract implementations to support custom implementations Algorithms defined in static utility methods that operate on collections (like Collections.sort(Listlist)) Infrastructure interfaces that support collections (like Iterator) Today we’ll learn a few basic concepts, then tour the collections library. CS1331 (Georgia Tech) Java Collections 3/ 12 TheCollectionInterface Collectionistherootinterface of the collections framework, declaring basic operations such as: add(E e)toaddelementstothecollection contains(Object key)todeterminewhetherthecollection contains key isEmpty()totestthecollection for emptiness iterator()togetaninterator over the elements of the collection remove(Object o)toremoveasingleinstanceofofromthe collection, if present size()tofindoutthenumberofelementsinthecollection Noneofthecollection implementations in the Java library implement Collectiondirectly. Instead they implement List or Set. CS1331 (Georgia Tech) Java Collections 4/ 12
no reviews yet
Please Login to review.