Students, please be sure to log in. This site does not use cookies and does not track/store work submitted when not signed in.
Unit 6 Problems
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!