只是个错误描述,文案而已
抛出错误后你就能看到你写的statement 1
抛出错误后你就能看到你写的statement 1
解决方案 »
- 关于加密移位问题
- 麻烦帮我看下这段代码不知道怎么回事~~快来人呐!!!
- Jlabel 类!
- 趣味思考题:请通过编程求解如下孙膑和庞涓问题。
- JDBC连接SQL库的出错的问题
- filechoose高级问题,请教高手~
- 一个强制类型转换的问题,有礼了!!
- 谢谢大家,请问一下有没有专门用swt的画界面的软件,linux和windows的软件都可
- 内隐类问题:为什么static inner class 可以被置于interface之中?
- 请教: game.chinaren.com中的游戏是怎样实现动画的?
- tomcat是先创建servlet对象还是先创建request和response对象
- java vs £define
statement 1 只是异常描述而已
比如下面的代码:package lianxi;
import java.util.Scanner;public class QuotienWithException {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter two integers:");
int n1 = input.nextInt();
int n2 = input.nextInt();
try{
if(n2 == 0)
throw new ArithmeticException("Divisor cannot be zero");
//上面的红色字部分代码,我发现不管写什么都没关系
System.out.println(n1 + "/" + n2 + "is" + n1/n2);
}
catch(ArithmeticException ex){
System.out.println("Exception: an integer" + "cannot be divided by zero");
}
System.out.println("Execution continues...");
}}
比如下面的代码:package lianxi;
import java.util.Scanner;public class QuotienWithException {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter two integers:");
int n1 = input.nextInt();
int n2 = input.nextInt();
try{
if(n2 == 0)
throw new ArithmeticException("Divisor cannot be zero");
//上面的红色字部分代码,我发现不管写什么都没关系
System.out.println(n1 + "/" + n2 + "is" + n1/n2);
}
catch(ArithmeticException ex){
System.out.println("Exception: an integer" + "cannot be divided by zero");
}
System.out.println("Execution continues...");
}}
红色字是用来描述异常的文本信息
和MsgBox里写的“Hello World”或者“你好”挺像,所以写什么都一样