Skip to editor
File
New File Ctrl+N
New Folder

Save Ctrl+S
Upload File…
Download as ZIP

Delete File

Reset Files…
View
Toggle Sidebar Ctrl+B
Toggle Terminal Ctrl+`

Word Wrap Alt+Z

Exercise Info
Run
Run Code Ctrl+Enter
Save & Run F5

Clear Output
CS174: OOP - Drills - Array Insert
Explorer
GitHub

Connect to GitHub to push and pull your project files to a repository.

On the page that opens, create a token with repo scope, copy it, then paste it below.

Paste the personal access token you created on GitHub with repo scope.

Click Refresh to load commit history
Exercise Info
← Prev Next →

Goals

  1. To do proper array indexing
  2. To use loops in concert with arrays
  3. To allocate and populate new arrays

Instructions

Modify the 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.



The Ursinus-WebIDE by Chris Tralie (opens in new tab) and Bill Mongan (opens in new tab)

Your browser does not support WebGL. A graphical rendering canvas would appear here.


          
No suggestions. Code quality feedback will appear here.
Not logged in java
Ln 1, Col 1