What will be the output of the following code?

Last Updated :
Discuss
Comments

What will be the output of the following code?

Java
import java.util.*;
public class Test {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.remove(1);
        System.out.println(list);
    }
}


[1, 3]


[2, 3]

[1, 2]

[1, 2, 3]

Share your thoughts in the comments