我可能只是累了。但无论我尝试过什么,代码总是会执行。我怎样才能让下面的代码只在字符串包含字符时才执行?
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);
}
}