How the try and catch blocks work?
For the following section of code from the class QueueInheritanceTest...how the try and catch blocks work?
The Class...
public class QueueInheritance extends List {
public QueueInheritance() { super( "queue" ); }
public void enqueue( Object o )
{ insertAtBack( o ); }
public Object dequeue()
throws EmptyListException { return removeFromFront(); }
public boolean isEmpty() { return super.isEmpty(); }
public void print() { super.print(); }
}
Testing...
public class QueueInheritanceTest {
public static void main( String args[] ){
QueueInheritance objQueue = new QueueInheritance();
// Create objects to store in the queue
Boolean b = Boolean.TRUE;
Character c = new Character( '$' );
Integer i = new Integer( 34567 );
String s = "hello";
// Use the enqueue method
objQueue.enqueue( b );
objQueue.enqueue( c );
objQueue.enqueue( i );
objQueue.enqueue( s );
objQueue.print();
// Use the dequeue method
Object removedObj = null;
try { while ( true ) {
removedObj = objQueue.dequeue();
System.out.println(removedObj.toString()+" dequeued" );
objQueue.print();
}
}
catch ( EmptyListException e ) {
System.err.println( "\n" + e.toString() );
}
}
}

