Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Remove ArrayList Elements using remove() function

import java.util.ArrayList;

class Main {
  public static void main(String[] args) {
    ArrayList<String> animals = new ArrayList<>();

    // add elements in the arraylist
    animals.add("Peacock");
    animals.add("Markhor");
    animals.add("Cow");
    System.out.println("ArrayList: " + animals +"
");

    // remove element from index 2
    String str = animals.remove(2);
    System.out.println("Updated ArrayList: " + animals);
    System.out.println("Removed Element: " + str);
  }
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Remove #ArrayList #Elements #function
ADD COMMENT
Topic
Name
6+4 =