title: How to generate 100 different reference variable inside a for loop and switch-case?
body: <p>I want to make 100 new instances based on <code>Position</code> enum types. In the switch case statement I have 5 cases, and based on the enum type I want to create corresponding <code>Employee</code> instances. My problem is, I have no idea how to create and assign new variable names, like: worker1, worker2, worker3 every time a new instance is created. Here is what I've come up so far:</p>
  
  <pre><code>final String randomVariableName() {
          int count = 1;
          String s = "worker" + count;
          count++;
          return s;
      }
  
  final Position randomPosition(){
      return positions[random.nextInt(positions.length)];
  }
  public void run() {
      for (int i = 1; i &lt;= 100; i++) {
          String randomName = "worker" + i;
          Position p = randomPosition();
          switch (p) {
              case PROJECT_LEADER:
                  ProjectLeader randomVariableName() = new ProjectLeader(p, randomName, 5000);
              case DEVELOPER_LEADER:
                  DeveloperLeader randomVariableName() = new DeveloperLeader(p, randomName, 1000);
          }
      }
  </code></pre>
  
  <p>But this way, I can't call the <code>randomVariableName()</code> method, because: <code>Variable 'randomVariableName' is already defined in the scope</code> </p>
  
  <p>I'm not even sure, that this would be the good solution. I just need a way, to create 100 unique reference variable name, in the switch-case.</p>