LLD - Behavioral Design Patterns — Part 2
What is wrong with this Java Memento pattern snippet?
class Memento {
private String state;
public Memento(String state) { this.state = state; }
public String getState() { return state; }
}
class Originator {
private String state;
public void setState(String state) { this.state = state; }
public Memento save() { return new Memento(state); }
public void restore(Memento m) { this.state = m.state; }
}