【发布时间】:2012-01-22 03:08:28
【问题描述】:
当尝试从标准中读取 int 时,我遇到了编译错误。
System.out.println("Hello Calculator : \n");
int a=System.in.read();
程序抛出异常:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type IOException at SamplePackege.MainClass.main(MainClass.java:15)
如何解决这个错误?
我的代码:
try {
Scanner sc = new Scanner(System.in);
int a=sc.nextInt();
} catch (Exception e) {
// TODO: handle exception
}
【问题讨论】:
-
先得到一个好的java教程。
-
我试图让问题变得更好,并提供了一个不错的答案。
标签: java exception exception-handling