Online Java Compiler By
JavaTpoint.com
import java.util.Collection; import java.util.concurrent.LinkedBlockingDeque; public class JavaCollectionClearExample1 { public static void main(String[] args) { Collection
collection = new LinkedBlockingDeque
(); collection.add(23); collection.add(123); collection.add(56); System.out.println("Collection : "+collection); System.out.println("After applying clear() method : "); // clear() method will erase the whole collection collection.clear(); System.out.println("Collection : "+collection); } }
Output