Online Java Compiler By
JavaTpoint.com
import java.net.HttpCookie; public class JavaHttpCookieDomainMatchesExample2 { public static void main(String[] args) { String domain = "www.google.com", host = "www.google.com"; HttpCookie cookie = new HttpCookie("Employee", "5"); //Returns true if the domain matches. Otherwise, returns false. System.out.println("Tests whether a host name lies in the domain or not: "+cookie.domainMatches(domain, host)); } }
Output