swap adjacent elements in arraylist java code example
Example: 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);
}
}