Java examples for Collection Framework:Array Element
Compare two short arrays.
//package com.java2s; public class Main { /**/*from w w w. j a va 2s. c o m*/ * Compare two short arrays. No null checks are performed. * * @param left * the first short array * @param right * the second short array * @return the result of the comparison */ public static boolean equals(short[] left, short[] right) { if (left.length != right.length) { return false; } boolean result = true; for (int i = left.length - 1; i >= 0; i--) { result &= left[i] == right[i]; } return result; } /** * Compare two two-dimensional short arrays. No null checks are performed. * * @param left * the first short array * @param right * the second short array * @return the result of the comparison */ public static boolean equals(short[][] left, short[][] right) { if (left.length != right.length) { return false; } boolean result = true; for (int i = left.length - 1; i >= 0; i--) { result &= equals(left[i], right[i]); } return result; } /** * Compare two three-dimensional short arrays. No null checks are performed. * * @param left * the first short array * @param right * the second short array * @return the result of the comparison */ public static boolean equals(short[][][] left, short[][][] right) { if (left.length != right.length) { return false; } boolean result = true; for (int i = left.length - 1; i >= 0; i--) { result &= equals(left[i], right[i]); } return result; } }