title: Java: can you change the value of the same string every time it loops?
body: <p>I'm doing a very basic calculator program in java that asks for the users input, and based on what he inputs(if "add" or else) either adds up the two values or subtracts them.</p>
  
  <p>The problem is, i want it to loop, so after every equation is finished and the result is displayed, it asks the user again if he wants to add or subtract. Is there any way, without using arrays, to change the value of the String each time the program loops?</p>
  
  <pre><code>import java.util.Scanner;
  
  public class BasicCalculator {
      public static void main(String[] args) {
  
          Scanner input = new Scanner(System.in);
  
          for(int i = 0; i&lt;999; i++) {
              System.out.println("Do you want to add or subtract?");
              String answer1 = input.nextLine();
              if (answer1.equalsIgnoreCase("add")) {
                  System.out.println("Enter first value");
                  int addv1 = input.nextInt();
                  System.out.println("Enter second value");
                  int addv2 = input.nextInt();
                  int ans = addv1 + addv2;
                  System.out.println("The answer is: " + ans);
              } else {
                  System.out.println("Enter first value");
                  int subv1 = input.nextInt();
                  System.out.println("Enter second value");
                  int subv2 = input.nextInt();
                  int ans2 = subv1 - subv2;
                  System.out.println("The answer is: " +ans2);
              }
          }
      }
  }
  </code></pre>