最简陋的版本...
public class Test
{
public static void main(String[] args) {
int n1 = Integer.parseInt(JOptionPane.showInputDialog("Input number 1: "));
int n2 = Integer.parseInt(JOptionPane.showInputDialog("Input number 1: "));
JOptionPane.showMessageDialog(null, "sum: " + (n1 + n2)
+ "\n" + "difference: " + (n1 - n2));
}
}