Here you can find the source of areEqual(Object o1, Object o2)
Parameter | Description |
---|---|
o1 | The first object to compare. |
o2 | The second object to compare. |
public static final boolean areEqual(Object o1, Object o2)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. * /* www .j a va 2 s. co m*/ * Contributors: * Oracle - initial API and implementation ******************************************************************************/ import java.util.Arrays; public class Main { /****************************************************************************** * Determines is two objects are equal, accounting for one or both * objects being null or the two objects being array types. * @param o1 The first object to compare. * @param o2 The second object to compare. * @return True if the two objects are equal. ******************************************************************************/ public static final boolean areEqual(Object o1, Object o2) { boolean objectsAreEqual = false; if (o1 == o2) { objectsAreEqual = true; } else if (o1 != null && o2 != null) { if (o1.getClass().isArray() && o2.getClass().isArray()) { objectsAreEqual = Arrays.equals((Object[]) o1, (Object[]) o2); } else { objectsAreEqual = o1.equals(o2); } } return objectsAreEqual; } }