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

 

simona1@sfusd.edu sorting > swapList
prev  |  next  |  chance

Swaps the elements at index1 and index2 of ArrayList a, then returns the array. Precondition: a will have a size of 2 or greater.


swapList([1, 3, 5, 7], 0, 3) → [7, 3, 5, 1]
swapList([1, 3, 99], 0, 1) → [3, 1, 99]
swapList([1, 3, 99], 1, 2) → [1, 99, 3]

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

public ArrayList <Integer> swapList(ArrayList <Integer> a, int index1, int index2){ }

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

Post-solution available

Copyright Nick Parlante 2017 - privacy