added singleton sample

This commit is contained in:
Ilkka Seppala
2014-08-11 21:43:08 +03:00
parent 01bdcdc1ed
commit 72415386fe
4 changed files with 51 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -0,0 +1,13 @@
package com.iluwatar;
public class IvoryTower {
private static IvoryTower instance = new IvoryTower();
private IvoryTower() {
}
public static IvoryTower getInstance() {
return instance;
}
}