Example of implementing a queue in Java