Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Creating a Collection

Although each collection class has its own characteristics, all of them implement the basic functionalities (enumeration, membership, and access). The methods that they use for these implementations are parallel and sometimes identical, but there are minor variations that reflect the difference in the classes. In this and the sections that follow, the main functions of collections are shown and compared.

The first thing you need to do with a collection is to create it. Class factory methods let you do this easily. You can start with an empty collection and then add to it as well as delete and rearrange it, or you can start with a populated collection. The difference is that in the first case, you need to create a mutable collection so that you can do your manipulation of the collection’s objects. In the second case, you just create and populate it in one step. If you are using a mutable collection, you can create and populate it in one step and then continue to manipulate the collection as you wish.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial