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 9-1 Adding Exceptions to the Queue Class

QExcDemo.java

In this project, you will create two exception classes that can be used by the queue classes developed by Project 8-1. They will indicate the queue-full and queue-empty error conditions. These exceptions can be thrown by the put( ) and get( ) methods, respectively. For the sake of simplicity, this project will add these exceptions to the FixedQueue class, but you can easily incorporate them into the other queue classes from Project 8-1.

1. Create a file called QExcDemo.java.

2. Into QExcDemo.java, define the following exceptions:

Image

A QueueFullException is generated when an attempt ...

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