import
java.util.concurrent.LinkedBlockingQueue;
import
java.util.Iterator;
public
class
GFG {
public
void
collectIterator()
{
int
capacityOfQueue =
7
;
LinkedBlockingQueue<Employee> linkedQueue
=
new
LinkedBlockingQueue<Employee>(capacityOfQueue);
Employee emp1 =
new
Employee(
"Sachin"
,
"Developer"
,
"39000"
);
Employee emp2 =
new
Employee(
"Sanjeev"
,
"Tester"
,
"26000"
);
linkedQueue.add(emp1);
linkedQueue.add(emp2);
Iterator<Employee> listOfEmployee = linkedQueue.iterator();
System.out.println(
"list of Employees:"
);
while
(listOfEmployee.hasNext()) {
System.out.println(
"*************************"
);
Employee emp = listOfEmployee.next();
System.out.println(
"Employee Name : "
+ emp.name);
System.out.println(
"Employee Position : "
+ emp.position);
System.out.println(
"Employee Salary : "
+ emp.salary);
}
}
public
class
Employee {
public
String name;
public
String position;
public
String salary;
Employee(String name, String position, String salary)
{
this
.name = name;
this
.position = position;
this
.salary = salary;
}
@Override
public
String toString()
{
return
"Employee [name="
+ name +
", position="
+ position +
", salary="
+ salary +
"]"
;
}
}
public
static
void
main(String[] args)
{
GFG gfg =
new
GFG();
gfg.collectIterator();
}
}