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

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...