Online Java Compiler By
JavaTpoint.com
import java.net.HttpCookie; public class JavaHttpCookieSetDiscardExample3 { public static void main(String[] args) { HttpCookie cookie1 = new HttpCookie("Student1", "101"); HttpCookie cookie2 = new HttpCookie("Student2", "102"); cookie1.setDiscard(false); cookie2.setDiscard(true); boolean bool1 = cookie1.getDiscard(); boolean bool2 = cookie2.getDiscard(); if(bool1) { System.out.println("Comment1: Discard attribute is present."); } else { System.out.println("Comment1: Discard attribute is not present."); } if(bool2) { System.out.println("Comment2: Discard attribute is present."); } else { System.out.println("Comment2: Discard attribute is not present."); } } }
Output