Online Java Compiler By
JavaTpoint.com
import java.net.HttpCookie; public class JavaHttpCookieGetMaxAgeExample2 { public static void main(String[] args) { HttpCookie cookie1 = new HttpCookie("Employee", "2"); HttpCookie cookie2 = new HttpCookie("Worker", "3"); cookie1.setMaxAge(2000); cookie2.setMaxAge(1000); System.out.println("The maximum age of the first cookie is given as: "+cookie1.getMaxAge()); System.out.println("The maximum age of the second cookie is given as: "+cookie2.getMaxAge()); } }
Output