计算器正常的程序打出来了,但是想要在1除0的时候出现中文错误的的字样
public static void main(String[] args) {
try {
int result=1/0;
}catch (Exception e) {
System.out.println("错误");
}
}
try-catch 一下 ,在 catch里面 输出 中文错误的信息
try {
// 处理。。。
} catch(Exception e) {
System.out.println("计算错误");
}