title: Assertion error with arrays
body: <pre><code>Public class Person {
      private Skill[] skills;
  
      public Skill[] getSkills() {
          return skills;
      }
  
      public void setSkills(Skill[] s) {
          if (s!= null) {
              skills = new Skill[s.length];
  
              for (int i = 0; i &lt; s.length; i++) {
                  skills[i] = s[i];
              }
          }
      }
  }
  }
  </code></pre>
  
  <p>Assume there is a class <code>skill</code>. The problem is there is a test case in Junit that tests the method setSkill ugiving s = the skills array itself. This test case returns <code>Assertion error</code> telling me <code>The returned skill array should be the same</code> knowing that when I change the <code>getSkill</code> to be giving both arrays same reference the test case passes.</p>
  
  <p>Can anyone help me with that please? how do I copy the elements not the reference? and why does the test case fails?</p>
  
  <p>the test case is :</p>
  
  <pre><code>@Test(timeout = 1000) 
  public void testGetSkills() { 
      instance.setSkills(skills); 
      assertSame("The returned skill array should be the same", instance.getSkills(), skills); 
  }
  </code></pre>