Q: Recursively Printing all Elements in a Queue without changing the queue's content I'm working with data structures and the effect that recursion has time complexity.  For one of the coding problems, they have a basic program involving a queue and have a number of tests that your algorithm should pass.  One of the methods is a method to print all elements in the queue without changing the content of the queue.  I cannot figure out how print them all out without removing the contents.  Below is the code I have so far (which doesn't work, stackOverflowError result) and the test the algorithm should pass.
My Code so far:
    public void printOut() {

        if (!q.isEmpty()) {
        System.out.println(q.getFirst());
        T value = q.removeFirst();
        printOut();
        q.addLast(value);
        }

Test algorithm should pass:
    public class TestQueuePrintOut {

@Test
public void test() {
    LinkedListQueue<String> queue = new LinkedListQueue<String>();
    queue.enqueue("first");
    queue.enqueue("second");
    queue.enqueue("third");
    queue.enqueue("fourth");
    System.out.println("Expected output:\nfirst\nsecond\nthird\nfourth\n");
    System.out.println("Resulting output of printOut:");
    queue.printOut();
    assertTrue(queue.dequeue().equals("first"));
    assertTrue(queue.dequeue().equals("second"));
    assertTrue(queue.dequeue().equals("third"));
    assertTrue(queue.dequeue().equals("fourth"));
}

}

Any help is greatly appreciated.  Thanks so much.
