Problem statement:
What will be the output of the following code?
What will be the output of the following code?
- import java.util.ArrayList;
- public class ArrayListExample {
- public static void main(String[] args) {
- ArrayList list = new ArrayList();
- list.add("a");
- list.add("b");
- list.add(1,"c");
- list.add("d");
- list.add(2,"e");
- System.out.println(list);
- }
- }
Output: [a, c, e, b, d]
No comments:
Post a Comment