Use Snip2Code for your private activities
Personal
Use Snip2Code together with your teams, colleagues and friends
Professional
Adopt Snip2Code in your company
Enterprise

 

SEARCH

Type simple keywords like "singleton" to search for the snippets you need, or try key-value pairs like OS=Windows to perform advanced search
inprogress
Retrieving Data ...


top
 

COLLECT

Add your own snippets: the title represents in few words which is the exact issue the snippet solves (like the name of a method).
In the description you can add interesting information (like the comment of a method).
The code is the actual content of the snippet: the stuff you want to copy-and-paste wherever you need.
Add some code to your snippet (at least 3 chars!!)
Or login using your account with:


top
 

SHARE

Decide who have access to your precious pearl of wisdom: may be restricted just to yourself, or to the entire world.
Moreover, if you belong to some groups (you can even create your own groups!), the snippet may be shared just with the belongers of such group, i.e. your colleagues, team-mates, or just friends!
My First Snippet: How to create a singleton in Java

How to safely implement singleton design pattern in Java

public class MyClass { 
    private static MyClass s_current; 
    private static Object s_objSync = new Object(); 
    private MyClass() {} 
    public static MyClass get() { 
        if (s_current == null) { 
            synchronized (s_objSync) { 
                if (s_current == null) 
                    s_current = new MyClass(); 
            } 
        } 
        return s_current; 
    } 
} 
Public Only me My Dev Team


 
top