• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

simple queue

does anyone have any examples of a Printer queue?

where you can add , docname, owner, size and position in queue

how to add data to queue
how to remove data from queue
how to remove item from anywhere in queue
total size of queue
check to see if its empty

1 Solution
What about a regular queue, of Objects of type PrinterJob (or something), each PrinterJob contains the the info.

public class PrinterQueue{
protected Vector jobs = new Vector(DEFAULT_LENGTH);

public int getSize(){
return jobs.size();

public void addJob(PrinterJob pj){

public PritnerJob removeNext(){
   return deleteJob(0);

public PritnerJob deleteJob(int jobId){
   return (PrinterJob) jobs.remove(jobId);

public boolean isEmpty(){
   return getSize() > 0 ? false : true;

Then in PrinterJob:

public class PrinterJob{
protected String docName;
public String getDocName(){
return docName;

That any help?


(NOTE: that code i wrote off the top of my head, so it will need a little work to compile).
You could just extends java.util.Stack. It pretty much offers the required functionality.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now