004-005-008
Array Copy: Data Backup
Easy
Problem Description
Array Copy: Data Backup
Learning Objective: Understand array copy methods and reference differences
Overview
Create a program to copy an array and verify that modifying the original array does not affect the copied array.
Specifications
- Create integer array
originalinitialized with {10, 20, 30} - Use
Arrays.copyOf()method to copy the array - Change the first element of the original array to 99
- Output the first element of both original and copied arrays
Output Format
Original: 99
Copy: 10
Hint: You need to import the java.util.Arrays class.
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
