0
我有一個程序,我正在捕捉一個錯誤。如果發生異常,我需要程序停止並保持空閒狀態。沒有System.exit的Java停止腳本繼續(1);
我有這樣的:
// Try to parse the integer just to make sure it's an integer.
try {
Integer.parseInt(celsiusTxtField.getText());
}
// Catch it if it's not an integer and murder the user for being stupid. They should know temperature consists of numbers and not letters.
catch(NumberFormatException e) {
JOptionPane.showMessageDialog(null, "You did not submit a number. Please try again.", "General Error - Error #2", JOptionPane.ERROR_MESSAGE);
}
但是,即使它顯示錯誤消息,它仍然繼續與該腳本。
這可能很簡單,但我是Java新手,所以請原諒我不知道。
爲什麼被標記爲「[php]」? – alex 2011-02-28 01:33:35
@Alex我通常用PHP編程,這是習慣的力量,哈哈。我修好了它。 :),對不起。 – 2011-02-28 01:35:17
- 這不是PHP - 顯示更多的代碼(明白爲什麼腳本繼續..我們需要您的問題 好運 – HulkThor 2011-02-28 01:36:56