Java comparison array
•
Java
I have two arrays of unknown types... One way to check elements is 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
Solution
ArrayUtils. Isequals () does this from Apache Commons It also handles multidimensional arrays
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码