Construct on-demand initialization. Put the getInstance method as the first class member.
Thread-safe singleton
Construct an on-demand initialization
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
return NestedSingletonHelper.singletonObject;
public class Singleton {
public static Singleton getInstance() {
}
public static Singleton singletonObject = new Singleton();
}
private static class NestedSingletonHelper {
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.