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