In this code fragment, I can\'t sum a and b:
String a = \"10\";
String b = \"20\";
JOptionPane.showMessageDialog(null,a+b);
public void actionPerformed(ActionEvent arg0)
{
String a= txtnum1.getText();
String b= txtnum2.getText();
String result = "";
try{
int value = Integer.parseInt(a)+Integer.parseInt(b);
result = ""+value;
}catch(NumberFormatException ex){
result = "Invalid input";
}
JOptionPane.showMessageDialog(null,result);
}
it is work