try{} catch(Exception e){} throws Exception
finally{}放在catch(Exception e){}后 不管处理怎么样finally{}都会执行
import java.util.Scanner;
public class yichang {
public static void main(String[] args)//throws Exception
{
A aa=new A();
try
{
aa.yc();
}
catch(Exception e)
{
System.out.println("输入有误");
}
}
}
class A{
void yc()//throws Exception
{
Scanner in=new Scanner(System.in);
System.out.println("请输入两位整数");
int a,b,c;
a=in.nextInt();
b=in.nextInt();
c=a%b;
System.out.println(c);
}
}