/**来自
N o w J a v a . c o m**/
/*
You may freely copy, distribute, modify and use this class as long
as the original author attribution remains intact. See message
below.
Copyright (C) 2003 Christian Pesch. All Rights Reserved.
*/
//package com.nowjava;
public class Main {
public static void main(String[] argv) throws Exception {
int[] first = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
int[] second = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
System.out.println(equals(first, second));
}
/**
* Returns if the given int arrays have the same length
* and contain the same values in the same order
*
* @param first the first array to compare
* @param second the second array to compare
* @return true if the given int arrays have the same length
* and contain the same values in the same order
*/
public static boolean equals(int[] first, int[] second) {
if (first == second)
/* from
时代Java公众号 - nowjava.com*/
return true;
if (first == null || second == null)
return false;
if (first.length != second.length)
return false;
for (int i = 0; i < second.length; i++) {
if (first[i] != second[i])
return false;
}
return true;
}
/**
* Returns if the given byte arrays have the same length
* and contain the same values in the same order
*
* @param first the first array to compare
* @param second the second array to compare
* @return true if the given byte arrays have the same length
* and contain the same values in the same order
*/
public static boolean equals(byte[] first, byte[] second) {
if (first == second)
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。