
Java提供了原始类型的解析方法。因此,根据您的输入,您可以使用Integer.parseInt,Double.parseDouble或其他。
String result;try{ int value = Integer.parseInt(a)+Integer.parseInt(b); result = String. valueOf(value) ;}catch(NumberFormatException ex){ //either a or b is not a number result = "Invalid input";}JOptionPane.showMessageDialog(null,result);欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)