title: Setting the name of a variable in an ArrayList equal to the value of a certain String in Java
body: <p>I am making a while loop that asks for a name and an id and adds it to an ArrayList repeatedly until told to stop for my computer science class. How could I get the name of the new "TeamMember" to change every time? Also, would that even work and if not why and how could I get it to work?
  This is my code (Main):</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Scanner;
  
  public class TeamClassMain {
  
  public static void main(String[] args) {
  
      Scanner scan = new Scanner(System.in);
      ArrayList &lt;TeamMember&gt; list = new ArrayList();
      String name;
      String id;
      String ArrayVar;
      int number = 0;
      int stop = 0;
      while (stop == 0) {
          System.out.println("Enter the next name:");
          name = scan.nextLine();
          name = name.toLowerCase();
          if (name == "stop") {
              stop = 1;
          }
          System.out.println("Enter the next ID:");
          id = scan.nextLine();
          ArrayVar = "member " + number;
          TeamMember member1 = new TeamMember(name, id);
          number++;
          }
     }  
  }
  </code></pre>
  
  <p>This isn't necessary, but it might be interesting to know what TeamMember is so this is my TeamMember class:</p>
  
  <pre><code>import java.lang.*;
  
  public class TeamMember {
  
  String fullName;
  String idString;
  
  TeamMember(String name, String id) {
      name = name.toUpperCase();
      char character;
      String string;
      int num;
      for (int i = 0; i &lt; name.length() - 1; i++) {
          if (i == 0) {
               character = name.charAt(0);
               string = "" + character;
               string = string.toUpperCase();
               character = string.charAt(0); 
               i = character;
          }
          if (name.charAt(i) == ' ') {
              character = name.charAt(i + 1);
              string = "" + character;
              string = string.toUpperCase();
              character = string.charAt(i + 1);
              name.substring(i + 1, character);
          }
      }
      fullName = name;
      idString.valueOf(id);
  }
  
  public String toString() {
      return fullName;    
  }
  
  int compareTo(TeamMember other) {
      return idString.compareTo(other.idString);
      }
  }
  </code></pre>