class Queue { private Cell front,back; public Object first() { return front.first; } public void leave() { front=front.next; if(front==null) back=null; } public void join(Object obj) { if(front==null) { front = new Cell(obj,null); back=front; } else { back.next = new Cell(obj,null); back=back.next; } } public boolean isEmpty() { return front==null; } private static class Cell { Object first; Cell next; Cell(Object f,Cell n) { first=f; next=n; } } }