Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; public class ArrayListClearExample2 { ArrayList
birds = new ArrayList<>(); birds.add("Parrot"); birds.add("Owl"); birds.add("Swallow"); System.out.println(birds); // ["Parrot", "Owl", "Swallow"] System.out.println(birds.size()); // prints: 3 birds.clear(); System.out.println(birds.size()); // prints: 0 System.out.println(birds); // [] }
Output