1D Arrays - Learning Objectives & Essential Knowledge
LEARNING OBJECTIVE		
Represent collections of related primitive or object reference data using one-dimensional (1D) array objects.		
Traverse the elements in a 1D array.		
For algorithms in the context of a particular specification that requires the use of array
traversals:
•	Identify standard algorithms.
•	Modify standard algorithms.
•	Develop an algorithm.		
Apply sequential/linear search algorithms to search for specific information in array objects.		
Apply selection sort and insertion sort algorithms to sort the elements of array objects.		
Compute statement execution counts and informal run-time comparison of sorting algorithms.		
Call static methods.		
Evaluate expressions that use the Math class methods.		

ESSENTIAL KNOWLEDGE		
The use of array objects allows multiple related items to be represented using a single variable.		
Initializer lists can be used to create and initialize arrays.		
Square brackets ([ ]) are used to access and modify an element in a 1D array using an index.		
Iteration statements can be used to access all the elements in an array. This is called traversing the array.		
Traversing an array with an indexed for loop or while loop requires elements to be accessed using their indices.		
When an array is created using the keyword new, all of its elements are initialized with a specific value based on the type of elements:
•	Elements of type int are initialized to 0
•	Elements of type double are initialized to 0.0
•	Elements of type boolean are initialized to false
•	Elements of a reference type are initialized to the reference value null. No objects are automatically created.		
Arrays can store either primitive data or object reference data.		
Since the indices for an array start at 0 and end at the number of elements
− 1, “off by one” errors are easy to make when traversing an array, resulting in an
ArrayIndexOutOfBoundsException being thrown.		
The size of an array is established at the time of creation and cannot be changed.		
An enhanced for loop header includes a variable, referred to as the enhanced for loop variable.		
For each iteration of the enhanced for loop, the enhanced for loop variable is assigned a copy of an element without using its index.		
Assigning a new value to the enhanced for loop variable does not change the value stored in the array.		
Program code written using an enhanced for loop to traverse and access elements in an array can be rewritten using an indexed for loop or a while loop.		
Static methods are called using the dot operator along with the class name unless they are defined in the enclosing class.		
The Math class is part of the java.lang  package.		
The Math class contains only static methods.		
The values returned from Math.random  can be manipulated to produce a random int or double  in a defined range.		
There are standard algorithms for searching.		
Sequential/linear search algorithms check each element in order until the desired value is found or all elements in the array have been checked.		
Data must be in sorted order to use the binary search algorithm.		
The binary search algorithm starts at the middle of a sorted array and eliminates half of the array in each iteration until the desired value is found or all elements have been eliminated.		
Binary search can be more efficient than sequential/linear search.		
The binary search algorithm can be written iteratively.		
Selection sort and insertion sort are iterative sorting algorithms that can be used to sort elements in an array.		
Informal run-time comparisons of program code segments can be made using statement execution counts.		
Merge sort is a recursive sorting algorithm that can be used to sort elements in an array or ArrayList.		
There are standard algorithms that utilize array traversals to:
•	Determine a minimum or maximum value
•	Compute a sum, average, or mode
•	Determine if at least one element has a particular property
•	Determine if all elements have a particular property
•	Access all consecutive pairs of elements
•	Determine the presence or absence of duplicate elements
•	Determine the number of elements meeting specific criteria		
There are standard array algorithms that utilize traversals to:
•	Shift or rotate elements left or right
•	Reverse the order of the elements		

Class Constructors and Methods	Explanation		
Integer Class	
Integer.MIN_VALUE	The minimum value represented by an int or Integer.		
Integer.MAX_VALUE	The minimum value represented by an int or Integer.		
Math Class	
int abs(int x)	Returns the absolute value of an int value		
double abs(double x)	Returns the absolute value of a double value		
double random()	Returns a double value greater than or equal to 0.0 and less than 1.0