Custom EXCEPTION source code

xiaoxiao2021-03-06  23

MyException.javaPackage fengbolai;

Public class myexception extends throwable {public string getMessage () {return "my error";}} a.javaPackage fengbolai;

Public class a {

Public void myfunction () throws myexception {throw new myexception ();}} B.javaPackage fengbolai;

Import java.io. *; public class b {

Public static void main (string [] args) {a a = new a (); try {a.myfunction ();} catch (myexception me) {system.out.println (me.getMessage ());}}}

转载请注明原文地址:https://www.9cbs.com/read-65335.html

New Post(0)