Java Number Equal areEqual(T s1, T s2)

Here you can find the source of areEqual(T s1, T s2)

Description

Compares two objects of the same type for equality taking into account that none, one, or both may be null

License

Open Source License

Parameter

Parameter Description
s1 a parameter
s2 a parameter

Declaration

public static <T> boolean areEqual(T s1, T s2) 

Method Source Code

//package com.java2s;
/**/*  ww w  .  j a v  a  2s  .  c  om*/
 * Aptana Studio
 * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions).
 * Please see the license.html included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */

public class Main {
    /**
     * Compares two objects of the same type for equality taking into account that none, one, or both may be null
     * 
     * @param s1
     * @param s2
     * @return
     */
    public static <T> boolean areEqual(T s1, T s2) {
        return (s1 == null) ? (s2 == null) : (s2 != null) ? s1.equals(s2) : false;
    }
}

Related

  1. areEqual(final char aThis, final char aThat)
  2. areEqual(float left, float right)
  3. areEqual(int align, int mask)
  4. areEqual(int i, int j)
  5. areEqual(int o1, int o2)
  6. areEqual(T... elements)
  7. areEquals(boolean first, boolean second)
  8. areEquals(double p, double q)