What will be the result of the following code?

Last Updated :
Discuss
Comments

What will be the result of the following code?

Java
import java.util.*; public class Test {  public static void main(String[] args) {  ArrayList<Integer> list = new ArrayList<>();  list.add(10);  list.add(20);  list.add(30);  list.add(40);  list.set(2, 50);  System.out.println(list);  } } 


[10, 20, 50, 40]


[10, 20, 30, 40]


[10, 20, 40, 50]

[50, 20, 30, 40]


Share your thoughts in the comments