diff --git a/pom.xml b/pom.xml index 88e3cdfab..7d8d0437a 100644 --- a/pom.xml +++ b/pom.xml @@ -22,5 +22,6 @@ builder factory-method prototype + singleton \ No newline at end of file diff --git a/singleton/pom.xml b/singleton/pom.xml new file mode 100644 index 000000000..f06044575 --- /dev/null +++ b/singleton/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + com.iluwatar + java-design-patterns + 1.0-SNAPSHOT + + com.iluwatar + singleton + 1.0-SNAPSHOT + singleton + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + diff --git a/singleton/src/main/java/com/iluwatar/App.java b/singleton/src/main/java/com/iluwatar/App.java new file mode 100644 index 000000000..bcfc338b0 --- /dev/null +++ b/singleton/src/main/java/com/iluwatar/App.java @@ -0,0 +1,14 @@ +package com.iluwatar; + +public class App +{ + public static void main( String[] args ) + { + + IvoryTower ivoryTower1 = IvoryTower.getInstance(); + IvoryTower ivoryTower2 = IvoryTower.getInstance(); + System.out.println("ivoryTower1=" + ivoryTower1); + System.out.println("ivoryTower2=" + ivoryTower2); + + } +} diff --git a/singleton/src/main/java/com/iluwatar/IvoryTower.java b/singleton/src/main/java/com/iluwatar/IvoryTower.java new file mode 100644 index 000000000..b676e3f69 --- /dev/null +++ b/singleton/src/main/java/com/iluwatar/IvoryTower.java @@ -0,0 +1,13 @@ +package com.iluwatar; + +public class IvoryTower { + + private static IvoryTower instance = new IvoryTower(); + + private IvoryTower() { + } + + public static IvoryTower getInstance() { + return instance; + } +}