Object.equals(Object) in Java

Object.equals(Object): This method is available in java.util.ArrayDeque class of Java.

Syntax:

boolean java.lang.Object.equals(Object obj)

This method takes one argument. This method indicates whether some other object is "equal to" this one.

Parameters: One parameter is required for this method.

obj: the reference object with which to compare.

Returns: true if this object is the same as the obj argument; false otherwise.

Exceptions: NA

Approach

Java

import java.util.ArrayDeque;

public class ArrayDequeequals {
    public static void main(String[] args) {

        ArrayDeque<Integer> arrayDeque =
new ArrayDeque<Integer>();

        arrayDeque.add(1);
        arrayDeque.add(4);

        ArrayDeque<Integer> arrayDeque2 =
new ArrayDeque<Integer>();

        arrayDeque2.add(1);
        arrayDeque2.add(4);

        System.out.println(arrayDeque.equals(arrayDeque2));

    }
}

Output:

false


No comments:

Post a Comment