CoreJava/exp9/ExceptionExample3.java
2024-05-09 09:10:51 +08:00

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!"); }
}
}