Wrox Programmer Forums
|
BOOK: Beginning Java 2
This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Java 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 4th, 2004, 01:14 PM
Authorized User
 
Join Date: Sep 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default Throwable 'causes'

I am still working my way through Ivor Horton's masterpiece (Great and challenging exercises!). At chapter 7 I found the Throwable class of the JDK 1.4 version have some new features that aren't covered in my JDK 1.3 book. Such as: one Exception can cause another Exception to be thrown, and this constitutes a hierarchy of causes for Throwables.

My QUESTIONS are:
- would Ivor have wanted me to delve into these myself?
- have these become essential features of the Java language?
- are these gonna be important for the Sun Certification?
- do you find these can be put to good use in your programs?

I find these rather esoteric features, but I may be wrong about these..

Long awaiting any answer..
- freeZotic
 
Old February 19th, 2004, 09:51 AM
Authorized User
 
Join Date: Sep 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Having studied the SDK1.4 API now, I'll answer my questions for myself:

From chapter 7 onwards, always have the new Java API opened whilst studying the book.

At the end of the chapter on Exceptions Ivor gives an example of how to provide the Exception message with more 'granularity'.
The new 'chained exception facility' uses causes for exactly the same purpose. So assigning a causing Exception to a newly created Exception is an essential feature of the Java language, and should be learned.
The SDK 1.4. API -see: class 'Throwable', explains how causes can be used, with a practical example.

There are two ways to create a 'cause' for any subclass of Throwable:
1. Use a constructor for your exception, that accepts a cause as an argument.
2. Use the Throwable method initCause() to initiate a cause for an existing exception.









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.