입력 문자열에 NumberFormatException
이 있는지 확인하는 것이 가능합니까? ""
?java.lang.NumberFormatException을 검사 할 수 있습니까?
if(pasientNavnFelt.getText() == null || pasientNrFeIt.getText() == null)
{
utskriftsområde.setText("ERROR, insert values");
}
if(pasientNavnFelt.getText() != null || pasientNrFeIt.getText() != null)
{
// rest of code here if the program had values in it
}
:
if(pasientNavnFelt.getText() == "" || pasientNrFeIt.getText() == "")
{
utskriftsområde.setText("ERROR, insert values");
}
if(pasientNavnFelt.getText() != "" || pasientNrFeIt.getText() != "")
{
// rest of code here if the program had values in it
}
나는 또한 null를 시도를 :
나는 사용자가 어떤 값을 넣어하지 않은 경우 오류 메시지가 NumberFormatException이 대신 나올 것이다 그래야 내 프로그램을 작성하려나는 아직도 얻을 :
,536,
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
값이 있으면 프로그램이 제대로 작동합니다.
물론 예외를 잡으십시오. –
try-catch 블록을 통합하여 예외를 처리하십시오. –