package try_catch_finally;
//package Throw.Exception;
import java.util.*;
class L2_2{
public static void main(String [] args)throws Exception
{
try
{
A Temp=new A();
Temp.InputShow();
}
catch(Exception e)
{
System.out.println("输入错误!!");
}
finally
{
System.out.println("程式继续执行");
}
}
}
class A{
public void InputShow()throws Exception
{
Scanner in=new Scanner(System.in);
System.out.print("输入第一个整数:");
int n=in.nextInt();
System.out.print("输入第二个整数:");
int x=in.nextInt();
int y=n%x;
System.out.println("取模值为:"+y);
}
}
package try_catch_throws_Exception;
import java.util.*;
class L2_2{
public static void main(String [] args)
{
try
{
A Temp=new A();
Temp.InputShow();
}
catch(Exception e)
{
System.out.println("输入错误!!");
}
System.out.println("程式继续执行");
}
}
class A{
public void InputShow()throws Exception
{
Scanner in=new Scanner(System.in);
System.out.print("输入第一个整数:");
int n=in.nextInt();
System.out.print("输入第二个整数:");
int x=in.nextInt();
int y=n%x;
System.out.println("取模值为:"+y);
}
}