On Mon, Apr 7, 2008 at 9:28 AM, Yossi Kreinin
<[email protected]> wrote:
>  My Java is quite rusty, but aren't Java methods supposed to declare their
> exceptions,

Only checked exceptions, i.e., everything not derived from
RuntimeException or Error.

(Otherwise you'd have to declare things such as "may throw
NullPointerException" or "may throw JvmOutofMemoryError [or whatever
it's called]" all over the place.)

> and wouldn't a theoretical possibility of a ClassCastException
> thus be a problem with generic methods?

ClassCast Exception is a subclass of RuntimeException, and therefore
an unchecked exception that can arise at any time without needing to
be declared.

Cheers,
-- 
Philip Newton <[email protected]>

Reply via email to