mirror of
https://github.com/DerTyp7/lf05-java.git
synced 2025-11-02 22:23:49 +01:00
add stuff
This commit is contained in:
25
src/singletonPattern/Singleton.java
Normal file
25
src/singletonPattern/Singleton.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package singletonPattern;
|
||||
|
||||
public class Singleton {
|
||||
private static Singleton instance;
|
||||
private String speicherOrt;
|
||||
|
||||
private Singleton(String speicherOrt){
|
||||
this.speicherOrt = speicherOrt;
|
||||
}
|
||||
|
||||
public static Singleton getInstance() {
|
||||
if(instance == null){
|
||||
instance = new Singleton("test");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getSpeicherOrt() {
|
||||
return speicherOrt;
|
||||
}
|
||||
|
||||
public void setSpeicherOrt(String speicherOrt) {
|
||||
this.speicherOrt = speicherOrt;
|
||||
}
|
||||
}
|
||||
9
src/singletonPattern/SingletonMain.java
Normal file
9
src/singletonPattern/SingletonMain.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package singletonPattern;
|
||||
|
||||
public class SingletonMain {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Singleton.getInstance().getSpeicherOrt());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user