title: How to remove all non-numerical characters from a string input in java?
body: <p>I am trying to create a basic calculator program and I want to remove all <strong><em>non-numerical characters</em></strong> from the string input. (I am a java <strong><em>newbie</em></strong>). This is my 
  current code:</p>
  
  <pre><code>package calculator;
  import javax.swing.JOptionPane;
  public class sub {
  
      public static void main(String[] args) {
  
          //Text &amp; Input Box #1
          String input = JOptionPane.showInputDialog(null,
                  "Input the first number",
                  "Subtraction",
                  JOptionPane.QUESTION_MESSAGE);
  
          //Input Box #2
          String input1 = JOptionPane.showInputDialog(null,
                  "Input the second number",
                  "Subtraction",
                  JOptionPane.QUESTION_MESSAGE);
  
          //Data Collection
          int data1 = Integer.parseInt(input);
          int data2 = Integer.parseInt(input1);
  
          //Data Sum
          int sum = data1 - data2;
  
          //Output
          JOptionPane.showMessageDialog(null,  sum, "The Answer",         
  JOptionPane.INFORMATION_MESSAGE);
  
      }
  }
  </code></pre>