public class ClassName {
        private static ClassName _INSTANCE = new ClassName();
        private ClassName() {}
        public static ClassName getInstance() {
          return _INSTANCE;
        }
        
      }
      
      Java language logo

      Create Singleton class

      singleton
      Java Public Recipes

      Singleton using private constructor

      Shortcut: class.singleton

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.