title: Why doesn't addition/subtraction symbol string splitting not work?
body: <p>Ok so I'm trying to make a command line calculator where it detects if your trying to add/subtract/multiply/divide using the String.contains method. Multiplication and division work just fine, but when I try to add or subtract, it spits out a bunch of errors. Can someone please tell me what I'm doing wrong? </p>
  
  <pre><code>import java.util.Scanner;
  
  public class CalculatorCode {
      public static void main(String[] args) {
          while(true){
               Scanner input = new Scanner(System.in);
               String userinput = input.nextLine();
      if(userinput.contains("x")){    
          String[] multiply = userinput.split("x");
          String multiply1 = multiply[0];
          String multiply2 = multiply[1];
          double a = Double.parseDouble(multiply1);
          double b = Double.parseDouble(multiply2);
          double multoutput = a * b;
          System.out.println(a + "x" + b + "=" + multoutput);
              }
      if(userinput.contains("/")){
          String[] divide = userinput.split("/");
          String divide1 = divide[0];
          String divide2 = divide[1];
          double c = Double.parseDouble(divide1);
          double d = Double.parseDouble(divide2);
          double divideoutput = c/d;
          System.out.println(c + "/" + d + "=" + divideoutput);
              }
      if(userinput.contains("-")){
          String[] subtract = userinput.split("-");
          String subtract1 = subtract[1];
          String subtract2 = subtract[2];
          double e = Double.parseDouble(subtract1);
          double f = Double.parseDouble(subtract2);
          double suboutput = e - f;
          System.out.println(e + "-" + f + "=" + suboutput);
              }
      if(userinput.contains("+")){
          String[] add = userinput.split("+");
          String add1 = add[1];
          String add2 = add[2];
          double g = Double.parseDouble(add1);
          double h = Double.parseDouble(add2);
          double addoutput = g - h;
          System.out.println(g + "-" + h + "=" + addoutput);
              }
          }
      }
  }
  </code></pre>
  
  <p>Errors for addition:</p>
  
  <pre>
  Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0
  +
  ^
      at java.util.regex.Pattern.error(Pattern.java:1713)
      at java.util.regex.Pattern.sequence(Pattern.java:1878)
      at java.util.regex.Pattern.expr(Pattern.java:1752)
      at java.util.regex.Pattern.compile(Pattern.java:1460)
      at java.util.regex.Pattern.(Pattern.java:1133)
      at java.util.regex.Pattern.compile(Pattern.java:823)
      at java.lang.String.split(String.java:2292)
      at java.lang.String.split(String.java:2334)
      at CalculatorCode.main(CalculatorCode.java:36)
  </pre>
  
  <p>Subtraction Errors:</p>
  
  <pre>
  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
      at CalculatorCode.main(CalculatorCode.java:29)
  </pre>