2

I need help with my Multidimensional int [][] in Java. The first one is:

int [][] startArr = {{0,1,2},{3,4,5},{6,7,8}};

The second is:

int [][] testArr = {{0,1,2},{3,4,5},{6,7,8}};

Arrays.deepEquals(startArr, testArr)

returns false...But why? If I have such a situation, I want to quit the program. At the moment I am inside of an infinite loop because this check doesn't work properly. If one value inside testArr has an other position (then there are two values in different positions of course) than in startArr, it should return false.

  • 4
    That code returns true for me. Can you please post your actual testing code? – azurefrog Jan 13 '16 at 21:57
  • 2
    That should work. You need to set a breakpoint at the `deepEquals()` line and examine the values in `startArr` and `testArr`. – Jim Garrison Jan 13 '16 at 21:59
  • Post an [MCVE](http://stackoverflow.com/help/mcve). Be sure to copy-paste your code to a *new project* and make sure it compiles and runs before posting it here. – user1803551 Jan 13 '16 at 21:59
  • I saw that I had a modification on the first array meanwhile, damn I am sorry for wasting your time... I thought I had removed all operations... –  Jan 13 '16 at 22:02
  • Your code is OK and return "true". Copy/paste: public static void main(String[] args) { int [][] startArr = {{0,1,2},{3,4,5},{6,7,8}}; int [][] testArr = {{0,1,2},{3,4,5},{6,7,8}}; System.out.println(Arrays.deepEquals(startArr, testArr)); } – Stéphane GRILLON Jan 13 '16 at 22:35

0 Answers0