title: Copying an Object in Java without affecting the original via copy constructor
body: <p>I'm trying to copy an Object, which will then be modified, without changing the original object.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/869033/how-do-i-copy-an-object-in-java">this solution</a> and it seemed the best approach would be a copy constructor - from my understanding, this would give me a deep copy (a completely separate object from the original).</p>
  
  <p>So I tried that. However, I've noticed that when the following code executes, it's effecting all previous objects from which it was copied. When I call <code>surveyCopy.take()</code>, which will change values inside of the <code>Survey</code>, it's also changing the values inside of selectedSurvey. </p>
  
  <pre><code>public class MainDriver {
  ...
  //Code that is supposed to create the copy
  case "11":  selectedSurvey = retrieveBlankSurvey(currentSurveys);
              Survey surveyCopy = new Survey(selectedSurvey);
              surveyCopy.take(consoleIO);
              currentSurveys.add(surveyCopy);
              break;
  }
  </code></pre>
  
  <p>and here is code for my copy constructor:</p>
  
  <pre><code>public class Survey implements Serializable
  {
      ArrayList&lt;Question&gt; questionList;
      int numQuestions;
      String taker;
      String surveyName;
      boolean isTaken;
  
      //Copy constructor
      public Survey(Survey incoming)
      {
          this.taker = incoming.getTaker();
          this.numQuestions = incoming.getNumQuestions();
          this.questionList = incoming.getQuestionList();
          this.surveyName = incoming.getSurveyName();
          this.isTaken = incoming.isTaken();
      }
  }
  </code></pre>
  
  <p>So what exactly is the issue? Does a copy constructor not work that way? Is the way I coded it wrong?</p>