Created
July 23, 2012 20:38
-
-
Save laymain/3166085 to your computer and use it in GitHub Desktop.
Java Quiz #45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.quiz.pkg; | |
public class Singleton | |
{ | |
private static final Singleton INSTANCE = new Singleton(); | |
public static Singleton getInstance() | |
{ | |
return INSTANCE; | |
} | |
private Singleton() | |
{ | |
// <clinit> are the static initialization blocks for the class. | |
if (!Thread.currentThread().getStackTrace()[2].getMethodName().equals("<clinit>")) | |
throw new SecurityException(); | |
} | |
public void sayHello() | |
{ | |
System.out.println("Hello World !"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment