Here you can find the source of memoryEqual(byte[] left, int leftOffset, byte[] right, int rightOffset, int length)
Parameter | Description |
---|---|
left | Left Array |
leftOffset | Starting Point of the Left Array |
right | Right Array |
rightOffset | Starting Point of the Right Array |
length | Length to be Compared from the Starting Point |
public static boolean memoryEqual(byte[] left, int leftOffset, byte[] right, int rightOffset, int length)
//package com.java2s; public class Main { /**************************************************************************************************** * Description: Checks Whether the Two Parts of Arrays are Equal to Each Other *//from w w w . j a va 2 s .c o m * @param left Left Array * @param leftOffset Starting Point of the Left Array * @param right Right Array * @param rightOffset Starting Point of the Right Array * @param length Length to be Compared from the Starting Point * * @return true Equal * false Different ****************************************************************************************************/ public static boolean memoryEqual(byte[] left, int leftOffset, byte[] right, int rightOffset, int length) { if ((leftOffset + length <= left.length) && (rightOffset + length <= right.length)) { for (int i = 0; i < length; i++) { if (left[leftOffset + i] != right[rightOffset + i]) { return false; } } return true; } else { return false; } } }