Here you can find the source of arrayEqualsExceptNull(Object[] a1, Object[] a2)
public static boolean arrayEqualsExceptNull(Object[] a1, Object[] a2)
//package com.java2s; /*/*from w w w .ja v a2s .c om*/ * Copyright (C) Jakub Neubauer, 2007 * * This file is part of TaskBlocks * * TaskBlocks is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * TaskBlocks is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { public static boolean arrayEqualsExceptNull(Object[] a1, Object[] a2) { if ((a1 == null) && (a2 == null)) { return true; } if (a1 == null && a2 != null && a2.length == 0) { return true; } if (a2 == null && a1 != null && a1.length == 0) { return true; } if (((a1 == null) && (a2 != null)) || ((a2 == null) && (a1 != null))) { return false; } if (a1.length != a2.length) { return false; } for (int i = 0; i < a1.length; i++) { if ((a1[i] == null) && (a2[i] == null)) { continue; } if ((a1 != null) && a1[i].equals(a2[i])) { continue; } return false; } return true; } }