title: Java - Define array size later
body: <p>So I wanna make an array outside a method so other methods can use it:</p>
  
  <pre><code>public int x = 0;
  public int[] myIntArray = new int[x];
  </code></pre>
  
  <p>But the x is 0, and is later defined in a method as a number entered by user:</p>
  
  <pre><code>x = input.nextInt();
  </code></pre>
  
  <p>But the method has already size 0, so how would I modify (redefine) the array's size? I tried to do it by defining the array in a method, but if I do that, I cannot access the array from another method. I am a beginner and I can't do ArrayList, is it possible to do this?</p>
  
  <p>EDIT: Basically: How do I define the size of an array later?</p>