(ArrayList<Integer> list, int idx1, int idx2)
| 1 | import java.util.ArrayList; |
| 2 | public class Swap { |
| 3 | public static void swap(ArrayList<Integer> list, int idx1, int idx2) { |
| 4 | int temp = list.get(idx1); |
| 5 | list.set(idx1, list.get(idx2)); |
| 6 | list.set(idx2, temp); |
| 7 | } |
| 8 | public static void main(String args[]) { |
| 9 | ArrayList<Integer> list = new ArrayList<>(); |
| 10 | list.add(2); |