id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2024_10_31_APP1SLHL_swapFirstAndLast
prev  |  next  |  chance

Write a method that has an integer array input parameter 'nums', which will have at least one element. Return 'nums' but with the first and last numbers in the array swapped. For example, if 'nums' is {1,2,3,4,5,6,7} you would return {7,2,3,4,5,6,1}. Look at the test data for more examples. Preconditions: 'nums' will be a non-empty array of integers.


test2024_10_31_APP1SLHL_swapFirstAndLast([4, 5]) → [5, 4]
test2024_10_31_APP1SLHL_swapFirstAndLast([7]) → [7]
test2024_10_31_APP1SLHL_swapFirstAndLast([800, 400, 100, 5]) → [5, 400, 100, 800]

...Save, Compile, Run (ctrl-enter)

public int[] test2024_10_31_APP1SLHL_swapFirstAndLast(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 230

Copyright Nick Parlante 2017 - privacy