Skip to content

Instantly share code, notes, and snippets.

@mindwing
Created December 12, 2015 02:27
Show Gist options
  • Save mindwing/332897edc5e31a99cb9d to your computer and use it in GitHub Desktop.
Save mindwing/332897edc5e31a99cb9d to your computer and use it in GitHub Desktop.
private 생성자에 관한 예제입니다.
/**
* Created by mindwing on 2015-12-12.
*/
public class Singleton {
private static Singleton instance = new Singleton();
private Singleton() {
}
public static Singleton getInstance() {
return instance;
}
}
/**
* Created by mindwing on 2015-12-12.
*/
public class SingletonTest {
public static void main(String[] args) {
// Singleton 클래스의 생성자가 private !!!
// Singleton singleton = new Singleton();
Singleton singleton = Singleton.getInstance();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment