确定两个数组是否相等如果两个数组的大小相同,则两个数组相等;如果对于数组中的每个位置,则两个相应的元素都相等
/* Copyright 1996-2008 Ariba, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. $Id: //ariba/platform/util/core/ariba/util/core/ArrayUtil.java#9 $ */ import java.io.PrintStream; import java.util.List; // 来自 nowjava - 时 代 Java public class Main{ public static void main(String[] argv) throws Exception{ Object[] a1 = new String[]{"1","abc","level",null,"nowjava.com","asdf 123"}; Object[] a2 = new String[]{"1","abc","level",null,"nowjava.com","asdf 123"}; System.out.println(arrayEquals(a1,a2)); } /** Determines if the two arrays are equal Two arrays are equal if their size is identical and if for each position in the array, both corresponding elements are equal @param a1 first array @param a2 second array @return <code>true</code> if the two arrays are equal @aribaapi documented */ public static boolean arrayEquals(Object[] a1, Object[] a2) { if (a1 == null && a2 == null) { return true; }/** 时代Java公众号 - N o w J a v a . c o m 提 供 **/ if (a1 == null || a2 == null) { return false;