[求助]一个有关简单计算器的问题
import javax.swing.JOptionPane;public class Caculator
{
public static void main(String args[])
{
String firstNumber,secondNumber,sign;
int number1,number2,results;
firstNumber=JOptionPane.showInputDialog("请输入一个整数");
sign=JOptionPane.showInputDialog("请输入一个运算符号");
secondNumber=JOptionPane.showInputDialog("请输入另一个整数");
number1=Integer.parseInt(firstNumber);
number2=Integer.parseInt(secondNumber);
if(sign=="+")
{
results=number1+number2;
JOptionPane.showMessageDialog(null,"结果是:"+results,"结果",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
else if(sign=="-")
{
results=number1-number2;
JOptionPane.showMessageDialog(null,"结果是:"+results,"结果",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
else if(sign=="*")
{
results=number1*number2;
JOptionPane.showMessageDialog(null,"结果是:"+results,"结果",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
else if(sign=="/")
{
results=number1/number2;
JOptionPane.showMessageDialog(null,"结果是:"+results,"结果",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
}
为什么我输不出结果呢?请解释下错误!谢谢