© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
V. SarcarJava Design Patternshttps://doi.org/10.1007/978-1-4842-7971-7_20

20. Memento Pattern

Vaskaran Sarcar1  
Garia, Kolkata, India

This chapter covers the Memento pattern.

GoF Definition

Without violating encapsulation, the Memento pattern captures and externalizes an object’s internal state so that the object can be restored to this state later.


As per the dictionary, the word memento is used as a reminder of past events. Following the object-oriented way, you can also track (or save) the states of an object. So, whenever you want to restore an object to its previous state, you can consider using this pattern.

In this pattern, you commonly see three ...

Get Java Design Patterns: A Hands-On Experience with Real-World Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.