Last active
July 13, 2016 13:47
-
-
Save mrWinston/bf748577d9d266e2646b to your computer and use it in GitHub Desktop.
Java Singleton by Enum #enum #singleton #pattern #design
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
/* This program is free software. It comes without any warranty, to | |
* the extent permitted by applicable law. You can redistribute it | |
* and/or modify it under the terms of the Do What The Fuck You Want | |
* To Public License, Version 2, as published by Sam Hocevar. See | |
* http://www.wtfpl.net/ for more details. | |
*/ | |
public enum EnumSingleton { | |
INSTANCE; | |
private int ; | |
EnumSingleton(){ | |
value=5; | |
} | |
public void foobar(){} | |
} | |
EnumSingleton.INSTANCE.foobar(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment