Java Singleton Pattern Hackerrank Solution
For Explanation Watch Video:
Sample Input
hello world
Sample Output
Hello I am a singleton! Let me say hello world to you
Code:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.lang.reflect.*;
class Singleton{
public String str;
private Singleton(){
}
public static Singleton getSingleInstance(){
return new Singleton();
}
}
Comments
Post a Comment