Programming Languages Java Subjective
Sep 24, 2025

Write a thread-safe Singleton using enum.

Detailed Explanation
public enum Singleton {\n INSTANCE;\n \n public void doSomething() {\n System.out.println("Doing something...");\n }\n}\n\n// Usage: Singleton.INSTANCE.doSomething();\n// This is thread-safe by default and prevents reflection attacks.
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback