title: Copy contents of an int array to a double array in Java?
body: <p>I'm trying to copy the contents of my int array into an array of type double.  Do I have to cast them first?</p>
  
  <p>I successfully copied an array of type int to another array of type int.
  However now I want to write code that would copy contents from Array <code>A</code> to Array <code>Y</code> (int to double).</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class CopyingArraysEtc {
  
      public void copyArrayAtoB() {
          double[] x = {10.1,33,21,9},y = null;
          int[] a = {23,31,11,9}, b = new int[4], c;
  
          System.arraycopy(a, 0, b, 0, a.length);
  
          for (int i = 0; i &lt; b.length; i++)
          {
              System.out.println(b[i]);
          }
  
      }          
  
      public static void main(String[] args) {
          //copy contents of Array A to array B
          new CopyingArraysEtc().copyArrayAtoB();
      }
  }
  </code></pre>