1. Features
The state class has the same public method
The state class has an attribute pointing to the entity class that uses this state
State The class automatically switches states internally, and the user cannot perceive it
Used to replace large blocks of repeated if statements
2, examples
package com.journaldev.design.state; public class TVStartState implements State { @Override public void doAction() { System.out.println("TV is turned ON"); } }
Collections in Java are mainly divided into four categories:
1. List: ordered and repeatable;
2.Queue: Yes Ordered, repeatable;
3. Set collection: non-repeatable;
4. Map mapping: unordered, with unique keys and non-unique values.
The above is the detailed content of What are the characteristics of java state pattern. For more information, please follow other related articles on the PHP Chinese website!