0
我正在使用try/catch作爲僅接受整數的對話框的錯誤輸入。我的電訊局長告訴我需要導入一些東西。我試過,但仍然獲得第8行同樣的錯誤:無法將NullPointerException解析爲變量
import java.lang.NullPointerException; //put this where it should be
try
{
buttons.rotatebutton(); //method I created
}
catch (NumberFormatException | NullPointerException e)
{
System.out.println("Please type a number");
if (e == NullPointerException) //ERROR OCCURS HERE
{
System.out.println("User cancelled");
}
}
任何人都可以提供一些線索?
的可能的複製[什麼是空指針異常,並且我怎麼修復它?(http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – LokiSinclair