title: Swap two strings in an array, Java
body: <p>I'm having a problem swapping two strings in my array. Let's say Array[0] is "Daniel" and Array[1] is "Paul", how do you go about switching them?</p>
  
  <p>This is my code and it just throws a bunch of errors at me.</p>
  
  <pre><code>public void swap()
  {
      String name1;
      String name2;
      String temp1;
      String temp2;
      System.out.print("\nWhich person would you like to swap?: ");
      name1 = input.next();
      System.out.print("Who are they swapping with?: ");
      name2 = input.next();
  
      for (int i = 0; i &lt;= 10; i++)
      {
          if(seats[i] == name1)
          {
              temp1 = name1;
              temp2 = name2;
              name1 = temp2;
              name2 = temp1;  
              return;
          }
      }
  
      System.out.println(name1 + " and " + name2 + " have been swapped.\n");
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated, thanks in advance.</p>