hacker rank 53rd java (java singleton pattern)

53. java singleton pattern

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.lang.reflect.*;



  class Singleton {
    private volatile static Singleton object;
    public static String str;
    private Singleton() {}
   
    static Singleton getSingleInstance() {
        if (object == null) {
            synchronized (Singleton.class) {
                if (object == null) {
                    object = new Singleton();
                }
            }
        }
        return  object;
    }

}


Compiler Message
Success
Input (stdin)Download
hello world
Expected OutputDownload
Hello I am a singleton! Let me say hello world to you

Comments

Popular posts from this blog

Amazon Web Services

Google Code-In mentorship experience :)

Hacker Rank all java and python problem solutions