import java.io.*;
class Compute {
public int devided(int i)throws ArithmeticException{
return 100/i;
}
public Compute(){
try{
int x;
x = System.in.read();
devided(x);
}
catch(ArithmeticException ae){
System.out.println("Devided by 0");
}
catch(IOException ioe){
System.out.println("Read Error");
}
}
}
public class ExceptionSample{
public static void main(String[] args){
new Compute();
}
}
class Compute {
public int devided(int i)throws ArithmeticException{
return 100/i;
}
public Compute(){
try{
int x;
x = System.in.read();
devided(x);
}
catch(ArithmeticException ae){
System.out.println("Devided by 0");
}
catch(IOException ioe){
System.out.println("Read Error");
}
}
}
public class ExceptionSample{
public static void main(String[] args){
new Compute();
}
}
解决方案 »
- java生成图片的问题
- ArrayList<E> 后面的 E 是什么意思?
- 求一个序列化对象的例子!!!!!!
- j2SE是否是个成熟的产品?我已经出离得愤怒了!
- 能不能在 class 内部 new 自己,会不会造成死循环,这样做有没有什么好处
- 为了这个问题,我在出200分。(呵呵,想出200分确不让,只好解决以后在开一100分的贴)
- java 正则表达式匹配字符串
- 这两个程序几乎是相同的,但结果却是不同的
- 如何通过pop3方式获得folder里面的邮件列表
- 鼠标双击和单击的区别
- 找不到符号?
- 两个ArrayList对象变量,如何生成一个HashMap<String key,ArrayList list>对象变量,有些挑战。。
但是System.in.read()是从标准输入上读一个字符 所以你输入一个0 x得到的值是'0'字符自动类型转换后的int值48