title: How to create a sub array from another array in Java?
body: <p>How to create a sub-array from another array? Is there a method that takes the indexes from the first array such as:</p>
  
  <pre><code>methodName(object array, int start, int end)
  </code></pre>
  
  <p>I don't want to go over making loops and making my program suffer.</p>
  
  <p>I keep getting error:</p>
  
  <blockquote>
    <p>cannot find symbol method copyOfRange(int[],int,int)</p>
  </blockquote>
  
  <p>This is my code:</p>
  
  <pre><code>import java.util.*;
  
  public class testing 
  {
      public static void main(String [] arg) 
      {   
          int[] src = new int[] {1, 2, 3, 4, 5}; 
          int b1[] = Arrays.copyOfRange(src, 0, 2);
      }
  }
  </code></pre>