title: Java Creating multiple arraylist
body: <p>The user will input a value between 1 and 5.
  Base on the input value, I would like to create multiple arraylist with different names.</p>
  
  <p>Example 1 (when input = 3) :</p>
  
  <pre><code>ArrayList&lt;String&gt; Group0 = new ArrayList&lt;&gt;();
  ArrayList&lt;String&gt; Group1 = new ArrayList&lt;&gt;();
  ArrayList&lt;String&gt; Group2 = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>Example 2 (when input = 5) :</p>
  
  <pre><code>ArrayList&lt;String&gt; Group0 = new ArrayList&lt;&gt;();
  ArrayList&lt;String&gt; Group1 = new ArrayList&lt;&gt;();
  ArrayList&lt;String&gt; Group2 = new ArrayList&lt;&gt;();
  ArrayList&lt;String&gt; Group3 = new ArrayList&lt;&gt;();
  ArrayList&lt;String&gt; Group4 = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>I apologise beforehand if this question seem trivial. I am relatively new to coding and thus would be very grateful to anyone who might know of an available method/command to get the above results. Thankyou!</p>
  
  <hr>
  
  <p>I have tried to do it this way but i cant seem to use "label" when initialising arraylist. The error states "variable label is already defined in method main(String[]). </p>
  
  <pre><code>public static void main(String[] args) {
  
      int userInput = 3;
      int count = 0;
  
      while(count &lt; (userInput)) {
          String label = "Group" + Integer.toString(count);
          ArrayList&lt;String&gt; label = new ArrayList&lt;&gt;();
          count++;
      }
  }
  </code></pre>