0% found this document useful (0 votes)
15 views7 pages

The List

This lesson introduces the concept of Lists as an advanced data structure that stores elements in an ordered manner, allowing for duplicates and accessed via indices. It includes an example application for managing a list of integers and a DIY project for creating a classlist management application for a teacher. The lesson concludes with a summary of the concepts covered and encourages further exploration.

Uploaded by

Percy Molalose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

The List

This lesson introduces the concept of Lists as an advanced data structure that stores elements in an ordered manner, allowing for duplicates and accessed via indices. It includes an example application for managing a list of integers and a DIY project for creating a classlist management application for a teacher. The lesson concludes with a summary of the concepts covered and encourages further exploration.

Uploaded by

Percy Molalose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Lesson: The List

Author: Vuyisile Memani

Date: 27 August 2023

Introduction

In this lesson we introduce the student to the concept of List. We explain the concept, follow that up
with an example and conclude with an exercise for the student to do.

What is a list?

A list is an advanced data structure that stores elements in an ordered manner. Elements are stored as
they are inserted. The list allows duplicate elements to be stored in it. Elements are accessed through
the index in the list.

Technically, the list is represented by the List interface. The interface is located in the java.util package.
The interface has several sub interfaces and classes that implement the interface. The figure in the
next page shows the inheritance hierarchy of the Queue interface.

As can be seen, the List interface uses generics, List<E>. The <E> could be any object. This means you
can have any object as a element of a list. An example of a List is an ArrayList class.
Some of the List methods are as follows:

The interface also inherits the following methods:

Let us take an example to demonstrate the implementation of the Queue interface.


Example

Create an application that will implement a list of integers: [1, 2, 3, 4, 5].

The application must perform the following operations on a List:

• Add numbers.
• Display all the numbers.
• Remove a number from the list.
• Search for a number.
• Update a number.
• Clear the list.

Solution

• Create a Java application called ListExample.


• Write the code
• Test the code.
DIY

Mulumba is a teacher by profession. He needs a console-based desktop application that he can use to
manage his classlist. His classlist consists of students. A student has a name, surname, student number
and a list of subjects done.

Mulumba approaches you with a request to create for hsim the application with the following
functionalities:

• Allow him to add a student in the classlist.


• Display the details of all the students in the classlist.
• Remove a student from the classlist.
• Search for a student.
• Update the details of a student. You can decide which part to update.
• Store the contents of the list in a text file.

Create such an application for Mulumba.

Conclusion

In this lesson we managed to introduce the student to the concept of Lists. We explained the
concept, did an example and concluded with an exercise for the student to do.

Thank you very much for having taken time to go through this lesson. Enjoy the rest of your day and
God bless you.

You might also like