title: Java Scanner input unequal to itself?
body: <p>I'm writing a loop that will exit when the Scanner receives the String value "end". However, when test with an "end" value, the loop continues. Logically if file = the input, then if(file=="end") is false, even though i typed in end! Are there visible errors in my code?</p>
  
  <pre><code>String file = "";
      Scanner in = new Scanner(System.in);
      ArrayList&lt;Integer&gt; fileInput = new ArrayList&lt;Integer&gt;(); 
  
      while(file!="end") {
          // Scan for filename/end program
          System.out.println("Provide the name of a file in the \"bin/\" folder, i will assume it's .txt");
          file = in.nextLine();
  
          System.out.println("." + file + ".");
          if(file!="end") {
              file= "bin/" + file + ".txt";
  
              // start reading
              try {
                  // If file found then carry on
                  BufferedReader openFile = new BufferedReader(new FileReader(file));
                  fileInput = readIn(openFile);
                  int lowerBound = getLower(fileInput);
                  int upperBound = getUpper(fileInput);
  
                  System.out.println("Lower Bound: " + lowerBound);
                  System.out.println("Upper Bound: " + upperBound);
  
                  // file not found
              } catch (FileNotFoundException e) {
                  System.out.println("File not found!");
              }
          }
      }
      System.out.println("Goodbye!");
      System.exit(0);
  </code></pre>