Java comparing Arrays
问题 I have two Arrays of unknown type...is there a way to check the elements are the same: public static boolean equals(Object a , Object b) { if (a instanceof int[]) return Arrays.equals((int[]) a, (int[])b); if (a instanceof double[]){ ////etc } I want to do this without all the instanceof checks.... 回答1: ArrayUtils.isEquals() from Apache Commons does exactly that. It also handles multi-dimensional arrays. 回答2: You should try Arrays.deepEquals(a, b) 回答3: Arrays utilities class could be of help