To clear an
ArrayList
in Java, call clear()
.Here's how you do it:
java.util.List<String> list = new java.util.ArrayList<>();
list.add("Hello");
list.add("World");
list.add("!");
System.out.println(list); // [Hello, World, !]
list.clear();
System.out.println(list); // []