What is the output of the following code? “`java List list = new ArrayList(); list.add(“A”); list.add(“B”); list.add(“C”); list.remove(1); System.out.println(list); “`

Java Associate Medium

Java Associate — Medium

What is the output of the following code? “`java List list = new ArrayList(); list.add(“A”); list.add(“B”); list.add(“C”); list.remove(1); System.out.println(list); “`

Key points

  • Removing an element at a specific index shifts the elements after it
  • The elements in the list are printed in the order they were added
  • The remove() method takes the index of the element to be removed

Ready to go further?

Related questions