title: setting two arrays equal to each other in java
body: <p>I am writing a program that has a double array called data.</p>
  
  <p>My code so far is the following.</p>
  
  <pre><code>public class DataSet {
  private double[] data;
  private int dataSize;
  
  public DataSet(){
      dataSize = 0;
      data = new double [10];
  }
  
  public void add(double x){
      if(dataSize&gt;= data.length){
          double[] newData = new double[data.length*2];
          System.arraycopy(data, 0, newData, 0, data.length);
          newData=data;
          newData[dataSize]=x;
          dataSize++;
      }
      else{
          data[dataSize] = x;
          dataSize++;
      }
  }
  }
  </code></pre>
  
  <p>as you can see I am adding new values to the array using the add method.
  However what I am unsure of is that when I do </p>
  
  <pre><code>newData=data;
  </code></pre>
  
  <p>Can I just make this change to the next line?</p>
  
  <pre><code>data[DataSize] = x;
  </code></pre>
  
  <p>The reason why I am asking is whether the by setting the two arrays equal to each other, whenever I call data, I am in fact calling newData. </p>