Javatpoint Logo
Javatpoint Logo

Java HttpCookie equals() Method

The equals(Object obj) method of HttpCookie class is invoked to test the equality of two HTTP cookies. The result is returned as true if the two cookies come from the same domain, having the same name and the same path.

Syntax

Parameter

The above method requires only one parameter:

  • obj - which denotes the reference object with which the comparison takes place.

Return

The above method is used to return true if the two HTTP cookies are equal. Otherwise, returns false.

Example 1

Test it Now

Output:

Both cookies come from same path and same domain.

Example 2

Test it Now

Output:

Cookies are different.

Example 3

Test it Now

Output:

Checks the first and second cookies if they are equal: true
Checks the third and fourth cookies if they are equal: false





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA