title: Why am I getting “ArrayIndexOutOfBoundsException: 0”? (array of string)
body: <p>I have in my code a procedure like this:</p>
  
  <pre><code>public void setawal(ArrayList&lt;String&gt; edge, String[] nodeforsub, int sizes){
      size=sizes;
      jumedge=new String[size];
      totalsubedge=new String[size];
      hasiljumedge=new String[size];
      hasilsubedge=new String[size];
      for(int j=0;j&lt;edge.size();j++){
          if(jumedge[0]==null){
              jumedge[0]=edge.get(j);
          }else{
              jumedge[0]=jumedge[0]+":"+edge.get(j);
          }
      }
      urutan=new int[edge.size()];
      for(int i=0;i&lt;edge.size();i++){
          urutan[i]=i;
      }
      node=nodeforsub;
      getsub(size, node, jumedge, totalsubedge, hasilsubedge, urutan);
  }
  </code></pre>
  
  <p>in my project, two classes will access this procedure, when the first class accesses this procedure it works properly, but when the second class accesses this procedure, it showed this error message: </p>
  
  <blockquote>
    <p>java.lang.ArrayIndexOutOfBoundsException: 0</p>
  </blockquote>
  
  <p>How can I fix it? </p>
  
  <p>I know the problem is when the second class tries to access <code>jumedge[0]</code>, but I am  confused why for first class it can access it properly?</p>