assertEquals fails to assert for arrays of primary data type

"XueFeng [email protected] [junit]" <[email protected]> Sun, 17 May 2015 22:00:03 +0800
Newsgroups gmane.comp.java.junit.user
Message-ID <[email protected]>
Hi,


I have tried JUnit 4.12. It seems that the assertion assertEquals for 
array does not work well. The following test is to report a failure:


     @Test
     public void testSame1(){
         int[] arr1 = new int[]{1, 2, 3};
         int[] arr2 = new int[]{1, 2, 3};
         assertEquals(arr1, arr2);
     }


While another test is passed:


     @Test
     public void testSame2(){
         String[] arr1 = new String[]{"Hello", "world"};
         String[] arr2 = new String[]{"Hello", "world"};
         assertEquals(arr1, arr2);
     }


Two arrays of the first test contain integers, the second test's contain 
objects. I wonder the assertEquals compares two arrays of primary data 
type by reference, while compares two arrays of class by their content. 
Is it right? If so, how can I compare two arrays of primary data type by 
their content? thanks!