Do you need help?

Java Reference Sheet
swap

Objective(s): Practice accessing the first and last elements of an array.

Given an array nums, swap the first and last elements.

Examples: 

 swap({ 0, 1, 2} )    -> [2, 1, 0]
 swap({ 5, 4, 3, 2} ) -> [2, 4, 3, 5]

This practice problem can help remind students of a very common error in programming when swapping the values of two variables! Make sure you pay attention to your error so you do not repeat it!

Skills Practiced:
3.D
4.A
4.B
Copyright © StudyCS 2025 All rights reserved.