標題:
例外處理- Exception ( try catch )
[打印本頁]
作者:
buy
時間:
2010-11-7 19:56
標題:
例外處理- Exception ( try catch )
try{
String strInput = jTextField1.getText();
double height = Double.parseDouble(strInput);
String strInput2 = jTextField2.getText();
double weight = Double.parseDouble(strInput2);
double BMI = weight / (height*height);
jLabel2.setText("您的BMI值為: " + BMI);
}
catch(Exception ex)
{
jLabel2.setText("發生無預期錯誤:" + ex.toString());
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2