Answers for "arraylist swap"

3

java array swap

public static void swap(int x, int y, int[] arr) {
  	int temp = arr[x];
  	arr[x] = arr[y];
  	arr[y] = temp;
}
Posted by: Guest on May-14-2020
2

Arraylist swap calues

public class ArrayListExample 
{
    public static void main(String[] args) 
    {
        ArrayList<String> list = new ArrayList<>(Arrays.asList("a", "b", "c", "d", "e", "f"));
         
        System.out.println(list);
         
        Collections.swap(list, 1, 2);
         
        System.out.println(list);
    }
}
Posted by: Guest on November-27-2020

Code answers related to "arraylist swap"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language