O'Reilly logo

Java, A Beginner’s Guide, 5th Edition by Herbert Schildt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Try This 6-2 Overloading the Queue Constructor

QDemo2.java

In this project you will enhance the Queue class by giving it two additional constructors. The first will construct a new queue from another queue. The second will construct a queue, giving it initial values. As you will see, adding these constructors enhances the usability of Queue substantially.

1. Create a file called QDemo2.java and copy the updated Queue class from Try This 6-1 into it.

2. First, add the following constructor, which constructs a queue from a queue.

Image

Look closely at this constructor. It initializes putloc and getloc to the values contained in the ob parameter. It then ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required