An overview of java collections, focusing on lists, linked lists, stacks, and queues. It covers the collection framework, the difference between records and objects in java, and the implementation of linked lists and stacks. The document also discusses the use cases and differences between linked lists and arrays, as well as common programming errors.
Download Java Collections: Understanding Lists, Linked Lists, Stacks, and Queues and more Slides Applications of Computer Sciences in PDF only on Docsity!
Chapter 13:
Collections: List
Creation and Maintenance
Object-Oriented Program
Development Using Java: A
Class-Centered Approach
Objectives
The Collection Framework
Linked Lists
Stacks
Queues
Common Programming Errors
Objects and Records
In real-world applications data is stored in records
Data items in records are data fields
In Java, records are implemented as objects
Linked Lists (continued)
Special reference is provided for storing the location of the first object in a list
Last record in the list will always have a null value for next item reference
Creating a linked list:
Use Java Collection Framework’s LinkedList class
Can also create your own
Constructing Your Own
Linked List
Provide each record with at least one reference variable - Include in the data declaration section
Links can be used to loop through a complete list
When to Use an Array or
LinkedList Container
Array:
Use for a list of primitive data types or objects that do not have to be expanded or contracted
LinkedList
Use for a list of objects that can be grouped as an array but must be expanded or contracted