Answers for "Arraylist swap calues"

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
1

java switch two items in an array

String temp = arr[1];
arr[1] = arr[2];
arr[2] = temp;
Posted by: Guest on October-15-2020

Code answers related to "Arraylist swap calues"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language