Collection
A number of
objects such as all the emails currently in your inbox
is called a collection. Do remember that class is
a blueprint not the object itself where as collection is
created with instances of each objects
This collection
is of objects which are all instances of the same class
(the class of emails).
A collection is
a list which we can put into order using
one or more of the properties of the objects in the
collect. Date order for example.
We can count
the number of items in a collection and we can
find those which match some criteria
(based on a property) such as “from my mother”.
We can assign an
index number to each object (or element) in a
collection. For example the ‘first’, ‘second’,
‘seventeenth’ or ‘last’ item. |