title: Add elements in ArrayList from user Input
body: <p>For practice I'm trying to create an list of limited size.</p>
  
  <p>Secondly, if size of an List is 5, then user will enter from console 5 different values one by one and once its reached 5 or entered all values, List will be showed up.</p>
  
  <p>I have written some </p>
  
  <pre><code>import java.util.Scanner;
  import java.util.*;
  
  public class Firstlastarray {
  
      public static List&lt;Integer&gt; Makearray(int arry) {
  
          List&lt;Integer&gt; mylist = new ArrayList&lt;Integer&gt;();
  
          mylist.add(arry);
  
          return mylist;
      }
  
      public static void main(String[] args) {
  
          Scanner ip = new Scanner(System.in);
          int ArrayElements = ip.nextInt();
          System.out.println(Makearray(ArrayElements));
  
      }
  
  }
  </code></pre>
  
  <p>I know where is the problem, Like Am giving an input from user but in code its no where written that how to keep taking from input from user till the max size of List and once reached to Max size...show the List with all elements user entered.</p>
  
  <p>For example, If size is 5,
  Then user will enter values from console one by one lets say</p>
  
  <pre><code>1
  2
  8
  9
  3
  </code></pre>
  
  <p>Max limit reached..</p>
  
  <p>Output would be <code>[1,2,8,9,3]</code></p>
  
  <p>But not getting any approach to achieve this...Any suggestions..?</p>