How do I restrict object creation not more than 3 in Java class?

后端 未结 8 1738
礼貌的吻别
礼貌的吻别 2020-12-10 18:25

How do I restrict object creation not more than 3 in Java class?

Can you give me an idea of how I can to do it?

8条回答
  •  难免孤独
    2020-12-10 19:17

    You need to modify singleton and create three objects.ans write three method in every method return object like as return different three objects and use when you needed. it main use no need to declare variable or object as static, because always return same object.

提交回复
热议问题