In this code fragment, I can't sum a
and b
:
String a = "10";
String b = "20";
JOptionPane.showMessageDialog(null,a+b);
Since a
and b
are defined as String
, this code will concatenate the strings and output 10+20=1020
.
How can I get it to instead sum a
and b
and output 10+20=30
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…