Answers for "clear an array list in java"

1

clear an array list in java

// Creates an array list
ArrayList<String> arrayList = new ArrayList<>();

// Adds stuff to array list
arrayList.add("test");

// Clears array list
arrayList.clear();
Posted by: Guest on October-10-2021
1

ArrayList clear() method in java

import java.util.ArrayList;
public class ArrayListClearMethodExample
{
   public static void main(String[] args)
   {
      ArrayList<Integer> al = new ArrayList<Integer>(4);
      al.add(9);
      al.add(3);
      al.add(5);
      al.add(1);
      System.out.println("ArrayList before clear() method: " + al);
      al.clear();
      System.out.println("ArrayList after clear() method: " + al);
   }
}
Posted by: Guest on October-29-2020
0

clear a list in java

list.clear();
Posted by: Guest on January-05-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language