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)
{
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库Java程序设计基础(题库)(8)在线全文阅读。
相关推荐: