repl.it
@ABHISHEKAREER/

Singleton Pattern

Java

No description

fork
loading
Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.lang.*;
import java.util.*;
import java.io.*;
class Demo
{
 static  Demo b=null;
  private Demo()
  {
    super();
  }
  static public Demo getDemo()
  {
    if(b==null)
    {
      b=new Demo();
      System.out.println("new o created");
    }
    return b;
  }
}
class Main
{
  public static void main(String [] aa)
  {
    Demo dd=Demo.getDemo();
    Demo d=Demo.getDemo();
    System.out.println(dd);
    System.out.println(d);
  }
}
Fetching token
?