Glossary
ArrayLists
A resizable array-like data structure in Java that can store objects, providing dynamic sizing and methods for adding, removing, and accessing elements.
Example:
An ArrayList ArrayList<String> names = new ArrayList<>(); can dynamically grow or shrink as you add or remove names.
Arrays
A fixed-size, ordered collection of elements of the same data type, accessed using an integer index.
Example:
An array int[] scores = {85, 92, 78}; stores three integer scores that can be accessed by scores[0], scores[1], etc.
Condition (For Loop)
The second part of a for loop's header, evaluated before each iteration; the loop continues to execute as long as this condition remains true.
Example:
In for (int i = 0; i < 5; i++), i < 5 is the condition that determines if the loop should run another time.
Control Structures
Mechanisms that dictate the flow of execution in a program, determining the order in which instructions are executed.
Example:
Conditional statements like if-else and loops are fundamental control structures that guide a program's decision-making and repetition.
For Loop
A control structure used for repeating a block of code a fixed number of times, typically when the number of iterations is known beforehand.
Example:
To print numbers from 1 to 10, you'd use a for loop like for (int i = 1; i <= 10; i++).
Increment/Decrement (For Loop)
The third part of a for loop's header, executed at the end of each loop iteration, typically used to update the loop control variable.
Example:
In for (int i = 0; i < 5; i++), i++ is the increment/decrement step that moves the loop variable forward.
Initialization (For Loop)
The first part of a for loop's header, executed only once at the very beginning, typically used to declare and set an initial value for the loop control variable.
Example:
In for (int i = 0; i < 5; i++), int i = 0 is the initialization step, setting i to its starting value.
While Loop
A control structure that repeatedly executes a block of code as long as a specified boolean condition remains true, often used when the number of repetitions is unknown.
Example:
A game might use a while loop like while (playerIsAlive) to keep the game running until the player's health drops to zero.