피곤할 수도 있습니다. 하지만 내가 뭘했는지에 상관없이 코드는 항상 실행됩니다. 문자열에 문자가 포함되어있는 경우에만 아래 코드를 실행하면 어떻게됩니까? 당신이 좋아하는 뭔가를 시도하는 것이 좋습니다JOptionPane.showInputDialog 문제
String input = JOptionPane.showInputDialog(this, "Enter your budget!", "Set Budget", 1);
//If the input isnt empty
System.out.println(input);
if(!"".equals(input) || input != null){
try{
budgetValue = Double.parseDouble(input);
budgetIn.setText(String.format("$%1$,.2f", budgetValue));
setDifference();
}
catch(Exception ex){
JOptionPane.showMessageDialog(this, "Unable to set budget!\n" +
"Please enter a usable value!", "Sorry!", 0);
}
}
if 조건문에서 OR (||) 대신 AND (&&) 연산자를 사용해야합니다. – ntalbs
또한 : 그 system.out.println() 나를 위해 문자열 null 실제로 볼 수 있습니다 –
오 남자. 고마워 .. 잠시 동안 자바 프로그래밍을 해왔고 결코 그 문제에 부딪치지 않았다. .. 왜 설명해 줄 수 있니? –