CS174: OOP - Drills - Array Insert
Developed by Professor Tralie and Professor Mongan.
Exercise Goals
The goals of this exercise are:- To do proper array indexing
- To use loops in concert with arrays
- To allocate and populate new arrays
insertElement
method in ArrayUtils.java
to insert an element at a particular index. For example, if you have the array {0, 5, 4, 8, 2}
and you insert the element 1
at index 2
, you should create a new array with the elements {0, 5, 1, 4, 8, 2}
. NOTE: The tediousness of this seemingly simple operation is what motivates us to use other data structures such as an ArrayList
or linked list.