Introduction to Java Through Game Development by 2023

Introduction to Java Through Game Development by 2023

Author:2023
Language: eng
Format: epub


CHAPTER 5

More Data Structures

Welcome to Chapter 5! In this chapter, we’ll spend some more time exploring some common data structures provided by the Java programming language. A brief summary of the data structures we’ll cover in this chapter is as follows:

• Multidimensional Arrays: Similar to the arrays you worked with

prior to this chapter, just with more dimensions, allowing us to map

tabular data, etc.

• Hashes: A very useful data structure that can be thought of as a

dictionary. Hashes store key-value pairs. Hashes are sometimes

referred to by their actual Java class name, Hashtable, or the

colloquial term, dictionary.

• Stacks: An important data structure that allows push and pop access

to a stack of values. These are the first data structures we’ve seen that remove their elements when they are accessed. They also have the

property that they return the element for you with a method call.

• Queues: Last but not least, the queue is a data structure you should be familiar with if you’ve ever had to wait in line for something. A

queue provides add or remove access to a list of values.

**Java Programming Note: All the data structures used in the text are either core features of the Java programming language or are contained in the java.util package. Add the line import java.util.* to use these classes in your programs.

Recall from our review in Chapter 3 that data structures are more advanced data types that hold other variables. Normally, data structures would be considered outside the scope of an introductory programming language text, but I feel that a gentle 111

© Victor G. Brusca 2023

V. G. Brusca, Introduction to Java Through Game Development, https://doi.org/10.1007/978-1-4842-8951-8_5



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.