Home > Java > javaTutorial > body text

What are the characteristics of java state pattern

王林
Release: 2023-04-29 14:40:10
forward
949 people have browsed it

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");
}
 
}
Copy after login

Java has Which collection classes

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template