Online Java Compiler By
JavaTpoint.com
import java.net.HttpCookie; public class JavaHttpCookieEqualsExample3 { public static void main(String[] args) { HttpCookie cookie1 = new HttpCookie("Employee", "01"); HttpCookie cookie2 = new HttpCookie("Employee", "01"); HttpCookie cookie3 = new HttpCookie("Employee1", "20"); HttpCookie cookie4 = new HttpCookie("Employee2", "30"); // Return true if the two HTTP cookies are equal. System.out.println("Checks the first and second cookies if they are equal: "+cookie1.equals(cookie2)); // Return false if the two HTTP cookies are not equal. System.out.println("Checks the third and fourth cookies if they are equal: "+cookie3.equals(cookie4)); } }
Output