title: Why I am getting the error?
body: <pre><code> import java.util.*;
  public class Nostalgia {
      static ArrayList&lt;Integer&gt; arr = new ArrayList&lt;Integer&gt;(5);
      static int array[] ={6,3,6,2,3};
      //static int num;
  public static void main(String args[]){
      Scanner s = new Scanner(System.in);
  
      arr.set(0, 8);
      arr.set(1, 4);
      arr.set(3, 6);
      arr.set(2, 9);
      arr.set(4, 7);
      arr.set(5, 1);
  
  
      System.out.print(3+" :"+arr.get(3));
  
  }
  }
  </code></pre>
  
  <p>I am getting this error.</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0</p>
    
    <p>at java.util.ArrayList.rangeCheck(Unknown Source)
      at java.util.ArrayList.set(Unknown Source)
      at Nostalgia.main(Nostalgia.java:9)</p>
  </blockquote>
  
  <p>I am trying to put some values in my List and display a value at a certain index. </p>