[JAVA] Singleton Pattern

Singleton Pattern Only one instance is created
</ font>

This page describes the following ・ Singleton Pattern sample code

Design Pattarm MENU

Check with the following class structure

class Explanation
singleton.class Create only one instance
user(Main.class) Create an instance
  • User Includes the meaning that other developers use this pattern

singleton.class


class singleton{
  private static singleton singleton = new singleton();
  private singleton(){}
  public  static singleton newInstance(){return singleton;}
}

user(Main.class)


public static  void main(String[] args){
  singleton s1 =singleton.newInstance();
}}

Recommended Posts

Singleton Pattern
Singleton pattern
[Java] Singleton pattern
Prototype pattern
Memento Pattern
Mediator pattern
Iterator pattern
Composite pattern
Observer Pattern
Builder pattern
Bridge Pattern
Command Pattern
Builder Pattern
Strategy pattern
Iterator Pattern
Visitor pattern
Adapter Pattern
Proxy Pattern
Strategy Pattern
Composite Pattern
Prototype Pattern
Facade Pattern
Decorator pattern
Flyweight Pattern
Decorator Pattern
Mediator Pattern
Facade pattern
Visitor Pattern
Bridge pattern
abstract Factory Pattern
Design pattern ~ Builder ~
[Java] Strategy pattern
Design pattern ~ Visitor ~
Java design pattern
Design pattern ~ Proxy ~
Design pattern ~ State ~
Factory Method Pattern
Design pattern ~ Strategy ~
Design pattern ~ Composite ~
Design pattern (1): AbstractFactory
Abstract Factory pattern
Design pattern ~ Iterator ~
Design pattern ~ Facade ~
Design pattern ~ Bridge ~
Design pattern ~ Mediator ~
Template Method pattern
Design pattern ~ Decorator ~
Template Method Pattern
Design pattern ~ Interpreter ~
Factory Method pattern
Design pattern ~ Observer ~
Design pattern ~ Prototype ~
[Java] Adapter pattern
Design pattern ~ Memento ~
Design pattern ~ Adapter ~
Design pattern ~ Flyweight ~
Java pattern memo