Saturday, April 27, 2019

what will be the output of the following code?

Problem statement:
What will be the output of the following code?
  1. import java.util.ArrayList;
  2. public class ArrayListExample {
  3.     public static void main(String[] args) {
  4.         ArrayList list = new ArrayList();
  5.         list.add("a");
  6.         list.add("b");
  7.         list.add(1,"c");
  8.         list.add("d");
  9.         list.add(2,"e");
  10.         System.out.println(list);
  11.     }
  12. }
Output: [a, c, e, b, d]

No comments:

Post a Comment

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...