Copying an Array

In this lesson, we explore how to make a duplicate copy of an array.

Sometimes we must make a distinct copy of an array. Perhaps we want to modify the contents of an array but retain the original data. By first copying the array, we can make our changes to the copy and still have the original version. At other times, an algorithm might require us to copy all or part of an array to another array. We can perform such tasks in one of several ways.

Our first techniques can create duplicate arrays, such as the duplicate arrays of integers pictured below.

Get hands-on with 1200+ tech skills courses.