You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

901 B

Singleton Blueprint

Instructions

You are given an incomplete Singleton class. Complete the class to demonstrate your understanding of how the Singleton design pattern works. The Singleton pattern ensures that a class has only one instance and provides a global point of access to that instance.

Expected Class

public class Singleton {
    public Singleton instance;

    private Singleton() {
    }

    public Singleton get???() {
    }

    public String whoAreYou() {
        return "Hello, I am a singleton!"
    }
}

Usage

Here is a possible ExerciseRunner.java to test your class:

public class ExerciseRunner {
    public static void main(String[] args) {
        System.out.println(Singleton.get???().whoAreYou());
    }
}

Expected Output

$ javac *.java -d build
$ java -cp build ExerciseRunner
Hello, I am a singleton!
$