Sonu2345 / HactoberFest23

A Repository For Hactoberfest 2023 where you can create pull requests and contribute for Hactoberfest 2023
14 stars 112 forks source link

Create ArrayBlockingQueue #69

Open djashan opened 1 year ago

djashan commented 1 year ago

import java.util.concurrent.ArrayBlockingQueue;

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

    animals.add("Dog");
    animals.add("Cat");
    animals.add("Horse");
    System.out.println("ArrayBlockingQueue: " + animals);

    // Using remove()
    String element1 = animals.remove();
    System.out.println("Removed Element:");
    System.out.println("Using remove(): " + element1);

    // Using poll()
    String element2 = animals.poll();
    System.out.println("Using poll(): " + element2);

    // Using clear()
    animals.clear();
    System.out.println("Updated ArrayBlockingQueue: " + animals);
}

}