21 lines
431 B
Java
21 lines
431 B
Java
package exp9;
|
|
|
|
class myexcep extends Exception
|
|
{
|
|
//myexcep()
|
|
//{System.out.println("Excep occured");}
|
|
}
|
|
public class ExceptionExample3
|
|
{
|
|
static void f1() throws myexcep
|
|
{ throw new myexcep(); }
|
|
public static void main(String args[])
|
|
{
|
|
try
|
|
{ f1(); }
|
|
catch(myexcep e1)
|
|
{System.out.println("Exception 1");}
|
|
finally //可要可不要的finally部分
|
|
{System.out.println("this part can remain or not!"); }
|
|
}
|
|
} |