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) {         LinkedList<Integer> list = new LinkedList<>();         list.add(10);         list.addFirst(5);         list.addLast(15);         System.out.println(list);     } } 


[10, 5, 15]

[5, 10, 15]


[5, 15, 10]

[10, 15, 5]

Share your thoughts in the comments