The Artima Developer Community
Sponsored Link

IOException thrown in constructor



This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


IOException thrown in constructor

Posted by Bob Hancock on 14 Oct 1998, 5:01 PM

First, let me say that your articles are great. The single most valuable Java reference on the Web. I just bought your book on the JVM and look forward to reading it.

I was reading Object Finalization and Cleanup , from the June 1998 issue of Javaworld. In particular, Approach 3 class LogFileTransaction. It all made perfect sense, until I tried to implement it.

class Scratch {
LogFile lf = new LogFile("jack.zap");

javac Exception can't be thrown in initializer.
LogFile lf = new LogFile("jack.zap");
1 error

Which seems to suggest the IOException can't be thrown in the constructor. Is this correct, or am I missing something?


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us