Re: [問題] 讀入字串判斷是否為數字的問題
推
03/05 00:57,
03/05 00:57
推
03/05 00:59,
03/05 00:59
您推的是這種嗎?
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
try{
System.out.print("請輸入你要的數字:");
int test = Integer.parseInt(buf.readLine());
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e.toString() + "陣列程式發生錯誤");
}
catch(ArithmeticException e)
{
System.out.println(e.toString() + "數學發生錯誤");
}
catch(Exception e)
{
System.out.println(e.toString() + "程式發生錯誤");
}
finally
{
System.out.println("執行成功");
}
--
********************************************************
* Appleboy Blog *
* http://blog.Wu-Boy.com/ *
* Appleboy Album *
* http://pic.wu-boy.com *
********************************************************
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.107.41
推
03/05 19:04, , 1F
03/05 19:04, 1F
※ 編輯: appleboy46 來自: 140.123.107.41 (03/05 21:02)
→
03/05 21:02, , 2F
03/05 21:02, 2F
推
03/05 22:13, , 3F
03/05 22:13, 3F
討論串 (同標題文章)