Describe the characteristics and applications of a collection.


Teaching Note:

- Contains similar elements.

LINK HL extension, recursive thinking.

LINK General principles of computational thinking, connecting computational thinking and program design.


Sample Question:


JSR Notes:

Characteristics of Collections:

A collection is any programming structure which is a group of similar elements. Though if you are talking about the Collection class of Java, they can in fact be collections different types. Still, most likely here is the idea that in general, a collection is a group of similar things. So:

General Definition: A collection of similar things. For example, arrays, or lists.

Application of Collections

Collections are used to conveniently work with groups, often large groups, of data. They have the advantage of offering a way to traverse through the data efficiently, via a for loop, using the index numbers of the data in the case of arrays, or using some sort of "getNext()" pointer in the case of lists. Another distinct advantage of having individual collections implemented as objects is that the object itself (i.e. the address of the array, which points to where it is, or the address of a list, which points to the list head) can be passed as a parameter; this saves on doubling up the memory required whenever working with a collection in another method.

Collections therefore are used continually in applications, whether it be collections of pixels on a screen, or collections of letters on a page, or collections of Student objects in a school database. Recall that computers are mainly good at two things: complex decision structures, and working with lots of things very quickly. The later needs some way to group these "lots of things", and it is collections, generally, which allow this.



Refer to 4.2.2 for a related assessment statement.


(The Java util package contains an abstract class called Collection from which specific implementations of it have been made, for example, ArrayList, and LinkedList and TreeSet. And if you really want to see ArrayList and/or LinkedList in operation at this point, you could look ahead to D.4.11

Also, it's worthy of note that Java arrays are not an implementation of the Collection. Arrays are a fundamental structure of Java. Yes, they generally can be seen as collections, but they are not implementation of the Collection class.)