added singleton sample
This commit is contained in:
		
							
								
								
									
										1
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -22,5 +22,6 @@ | ||||
|     <module>builder</module> | ||||
|     <module>factory-method</module> | ||||
|     <module>prototype</module> | ||||
|     <module>singleton</module> | ||||
|   </modules> | ||||
| </project> | ||||
							
								
								
									
										23
									
								
								singleton/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								singleton/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| <?xml version="1.0"?> | ||||
| <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||||
|   <modelVersion>4.0.0</modelVersion> | ||||
|   <parent> | ||||
|     <groupId>com.iluwatar</groupId> | ||||
|     <artifactId>java-design-patterns</artifactId> | ||||
|     <version>1.0-SNAPSHOT</version> | ||||
|   </parent> | ||||
|   <groupId>com.iluwatar</groupId> | ||||
|   <artifactId>singleton</artifactId> | ||||
|   <version>1.0-SNAPSHOT</version> | ||||
|   <name>singleton</name> | ||||
|   <url>http://maven.apache.org</url> | ||||
|   <dependencies> | ||||
|     <dependency> | ||||
|       <groupId>junit</groupId> | ||||
|       <artifactId>junit</artifactId> | ||||
|       <version>3.8.1</version> | ||||
|       <scope>test</scope> | ||||
|     </dependency> | ||||
|   </dependencies> | ||||
| </project> | ||||
							
								
								
									
										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