Java HttpCookie domainMatches() Method

The domainMatches(String domain, String host)method of HttpCookie class is used to check whether a host name lies in a domain or not.

Syntax

Parameter

The above method requires two parameters:

  • domain - denotes the domain name in order to check the host name.
  • host - denotes the host name in question.

Return

The above method is used to return true if the domain matches. Otherwise, returns false.

Example 1

Test it Now

Output:

Tests whether a host name lies in the domain or not: false

Example 2

Test it Now

Output:

Tests whether a host name lies in the domain or not: true

Example 3

Test it Now

Output:

Tests whether the first host name lies in the first domain or not: true
Tests whether the second host name lies in the second domain or not: false
Next Topicequals() Method




Latest Courses