CS 121 Lecture Notes - Lecture 78: Abstract Data Type

29 views2 pages
Collection & Data Structures:
Collection: an object that serves as a repository for other objects.
oA generic term that can be applied to many situations.
oUsually used when discussing an object whose specific role is to provide
services to add, remove, & otherwise manage elements that are contained
within.
EX: The ArrayList class represents a collection.
Provides methods to add elements to end of a list or to a particular
location in the list based on an index value.
Provides methods to remove specific elements as needed.
oSome collections maintain elements in a specific order, while others
don’t.
Some collections are homogeneous: they can contain all of the same
type of object.
Other collections are heterogeneous: they can contain objects of
various types.
An ArrayList that doesn’t specify an explicit element type can
be thought of as heterogeneous b/c it can hold an object of any
type.
Its heterogeneous nature comes from the fact that an ArrayList
stores Object references.
It can store any object b/c of inheritance & polymorphism:
the condition of occurring in several different forms.
Separating Interface From Implementation
A crucial aspect of collections is that they can be implemented in a variety of
ways.
oUnderlying data structure that stores objects can be implemented using
various techniques.
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Ex: the arraylist class represents a collection. Provides methods to add elements to end of a list or to a particular location in the list based on an index value. Provides methods to remove specific elements as needed: some collections maintain elements in a specific order, while others don"t. Some collections are homogeneous: they can contain all of the same type of object. Other collections are heterogeneous: they can contain objects of various types. An arraylist that doesn"t specify an explicit element type can be thought of as heterogeneous b/c it can hold an object of any type. Its heterogeneous nature comes from the fact that an arraylist stores object references. It can store any object b/c of inheritance & polymorphism: the condition of occurring in several different forms. All operations on an arraylist are accomplished by invoking methods that perform appropriate operations on the underlying array.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions