public final class Singleton { // Single instance private static Singleton instance = null; // Prevent instantiation from other classes by making constructor private private Singleton() {} // Method to get the single instance public static Singleton getInstance() { if (instance == null) instance = new Singleton(); return instance; } // Method to demonstrate Singleton usage logging messages to the terminal public void logMessage(String message) { System.out.println("Log Message: " + message); } }