PatternSingleton: Initial commit
This commit is contained in:
6
System Development/PatternSingleton/.classpath
Normal file
6
System Development/PatternSingleton/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
System Development/PatternSingleton/.project
Normal file
17
System Development/PatternSingleton/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>PatternSingleton</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,9 @@
|
||||
public class PatternSingleton {
|
||||
public static void main(String[] args) {
|
||||
//Get the only object available
|
||||
Singleton object = Singleton.getInstance();
|
||||
|
||||
//show the message
|
||||
object.showMessage();
|
||||
}
|
||||
}
|
||||
19
System Development/PatternSingleton/src/Singleton.java
Normal file
19
System Development/PatternSingleton/src/Singleton.java
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
public class Singleton {
|
||||
|
||||
//create an object of SingleObject
|
||||
private static Singleton instance = new Singleton();
|
||||
|
||||
//make the constructor private so that this class cannot be
|
||||
//instantiated
|
||||
private Singleton(){}
|
||||
|
||||
//Get the only object available
|
||||
public static Singleton getInstance(){
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void showMessage(){
|
||||
System.out.println("There can be only One!");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user