added singleton sample
This commit is contained in:
14
singleton/src/main/java/com/iluwatar/App.java
Normal file
14
singleton/src/main/java/com/iluwatar/App.java
Normal 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);
|
||||
|
||||
}
|
||||
}
|
13
singleton/src/main/java/com/iluwatar/IvoryTower.java
Normal file
13
singleton/src/main/java/com/iluwatar/IvoryTower.java
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user