Java题库练习!!!
知识点:异常
1.本程序为从控制台读取一个字符
public class SqrtException {
public SqrtException() {
}
public static void main(String[] args) {
try {
int ch=System.in.read();
}catch(Exceptione){
System.out.println(getMessage()); //显示异常信息
}finally{
System.out.println("into finally");
}
}
}
2.本程序为把字符串转换为相应的整形数值。
public class ExT {
public ExT() {
}
public static void main(String[] args) {
int n=0,m=0,t=555;
try {
m=Integer.parseInt("8888");
n=Integer.parseInt("abc789");
t=9999;
} catch (NumberFormatException e)
{