import
java.util.Iterator;
import
java.util.concurrent.LinkedBlockingQueue;
public
class
GFG {
public
void
removeDemo()
throws
InterruptedException
{
int
capacityOfQueue =
5
;
LinkedBlockingQueue<Employee> linkedQueue
=
new
LinkedBlockingQueue<Employee>(capacityOfQueue);
Employee emp1 =
new
Employee("Ranjeet", "Tester", "
29000
",
27
);
Employee emp2 =
new
Employee("Sanjeet", "Manager", "
98000
",
34
);
Employee emp3 =
new
Employee("Karan", "Analyst", "
44000
",
30
);
linkedQueue.put(emp1);
linkedQueue.put(emp2);
linkedQueue.put(emp3);
System.out.println("Before removing Elements");
Iterator itr = linkedQueue.iterator();
while
(itr.hasNext())
System.out.println(itr.next());
linkedQueue.remove(emp2);
linkedQueue.remove(emp1);
System.out.println("After removing Some Elements");
itr = linkedQueue.iterator();
while
(itr.hasNext())
System.out.println(itr.next());
}
public
class
Employee {
public
String name;
public
String position;
public
String salary;
public
int
Age;
Employee(String name, String position,
String salary,
int
age)
{
this
.name = name;
this
.position = position;
this
.salary = salary;
this
.Age = age;
}
@Override
public
String toString()
{
return
"Employee [name=" + name + ", position="
+ position + ", salary=" + salary + ", Age=" + Age + "]";
}
}
public
static
void
main(String[] args)
{
GFG gfg =
new
GFG();
try
{
gfg.removeDemo();
}
catch
(InterruptedException e) {
e.printStackTrace();
}
}
}