import
java.util.concurrent.LinkedBlockingQueue;
public
class
GFG {
public
void
findPeek()
{
int
capacityOfQueue =
7
;
LinkedBlockingQueue<Employee> linkedQueue
=
new
LinkedBlockingQueue<Employee>(capacityOfQueue);
Employee emp1 =
new
Employee(
"Ravi"
,
"Tester"
,
"39000"
);
Employee emp2 =
new
Employee(
"Sanjeet"
,
"Manager"
,
"98000"
);
linkedQueue.add(emp1);
linkedQueue.add(emp2);
while
(linkedQueue.size() !=
0
) {
Employee head = linkedQueue.peek();
System.out.println(
"Head of list"
);
System.out.println(
"Employee Name : "
+ head.name);
System.out.println(
"Employee Position : "
+ head.position);
System.out.println(
"Employee Salary : "
+ head.salary);
linkedQueue.remove();
if
(linkedQueue.size() !=
0
)
System.out.println(
"\nRemoving one element from Queue\n"
);
}
}
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.findPeek();
}
}