异常抛出(不含try...catch...)

package kkk;
class DivideException extends Exception{
	public DivideException(){
		super();
	}
	public DivideException(String message){
		super(message);
	}
}
public class Test {
	public static void main(String args[])throws DivideException{
			int result = divide(4,0);
			System.out.println(result);
			}
	public static int divide(int x, int y)throws DivideException{
		int result = x/y;
		return result;
	}
}

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页