⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teexption.java

📁 用java编写的一些初级代码
💻 JAVA
字号:
class DevideByExcep extends Exception
{
    int devisor;
    public DevideByExcep(String msg ,int devisor)
    {
	super (msg);
	this.devisor=devisor;
    }
    public int getDevisor()
    {
	return devisor;
    }
}
public class TeExption
{
    public static void main (String[] args)
    {
	try
	{
	    int result= new Test().devide(3,-12);
	    System.out.println("the result is "+result);
	}
	catch (DevideByExcep e)
	{
	    System.out.println(e.getMessage());
	    System.out.println("the devisor is "+e.getDevisor());
	}
	catch (Exception e)
	{
	    System.out.println(e.getMessage());
	    e.printStackTrace();
	}
	System.out.println("pro is runing");
    }
}
class Test
{
    public int devide(int x,int y)throws Exception
    {
	if(y < 0)
	    throw new DevideByExcep("被除数为负",y);
	int result=x/y;
	return result;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -