CoreJava/exp9/ExceptionExample3.java

21 lines
431 B
Java
Raw Normal View History

2024-05-09 09:10:51 +08:00
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!"); }
}
}