Online Java Compiler By
JavaTpoint.com
import java.net.HttpCookie; public class JavaHttpCookieGetDomainExample2 { public static void main(String[] args) { HttpCookie object1 = new HttpCookie("Parent1", "1"); HttpCookie object2 = new HttpCookie("Parent2", "2"); object1.setDomain("www.google.com"); object2.setDomain("www.javatpoint.com"); //Returns the domain name. System.out.println("The first domain name is given as: "+object1.getDomain()); System.out.println("The second domain name is given as: "+object2.getDomain()); } }
Output