Class ArrayUtil


  • public class ArrayUtil
    extends Object
    Provides hashCode, equals and toString methods that can handle array.
    • Constructor Detail

      • ArrayUtil

        public ArrayUtil()
    • Method Detail

      • hashCode

        public static int hashCode​(Object obj)
        Returns a hash code for obj.
        Parameters:
        obj - The object to get a hash code for. May be an array or null.
        Returns:
        A hash code of obj or 0 if obj is null
      • equals

        public static boolean equals​(Object thisObj,
                                     Object thatObj)
        Compares two objects. Returns true if
        • thisObj and thatObj are both null
        • thisObj and thatObj are instances of the same type and Object.equals(Object) returns true
        • thisObj and thatObj are arrays with the same component type and equals() method of Arrays returns true (not deepEquals())
        Parameters:
        thisObj - The left hand object to compare. May be an array or null
        thatObj - The right hand object to compare. May be an array or null
        Returns:
        true if two objects are equal; false otherwise.
      • toString

        public static String toString​(Object obj)
        If the obj is an array, toString() method of Arrays is called. Otherwise Object.toString() is called. Returns "null" if obj is null.
        Parameters:
        obj - An object. May be an array or null.
        Returns:
        String representation of the obj.