Question: I am trying to assert that an array of string elements is one of the elements of a 2-dimensional array using the standard **Collection.isIn** matcher provided with Hamcrest library. Unfortunately receiving the following assertion exception: 

```
java.lang.AssertionError: 
Expected: one of {["A", "B", "C"], ["A", "B", "C"]}
   but: was ["A", "B", "C"]

```

**Code:**

```
String[][] expected = new String[][] { { "A", "B", "C" }, { "A", "B", "C" } };
String[] actual = new String[] { "A", "B", "C" };

assertThat(actual, isIn(expected));

```

Can I validate using hamcrest in such a manner? Or do I need to create my own matcher for the given scenario?

Answer: 
First of all, you would be better off using `List<>` instead of arrays.

Secondly, yes, if you insist on using arrays, you will need to write your own 'array-contains-element' function. You can implement this function using a loop over the major dimension of the array, invoking the `Arrays.equals()` method to compare the contents of two one-dimensional arrays.
I'm guessing the issue is because the method compares objects, and not contents. Basically, even though both have the same content, they are not the same object. [See here in the docs](http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matcher.html#matches(java.lang.Object))

Do this instead:

`String[] actual = new String[]{"A1 C1 E1 F1 J1", "A1 C1 E1 F1 K1", "A1 B1 G1 H1"};
String[][] expected = new String[][]{actual, {"A1 C1 E1 F1 J1", "A1 C1 E1 F1 K1", "A1 B1 G1 H1"}};`