What is the preferred Throwable to use in a private utility class constructor?

前端 未结 8 1290
青春惊慌失措
青春惊慌失措 2020-12-14 01:07

Effective Java (Second Edition), Item 4, discusses using private constructors to enforce noninstantiability. Here\'s the code sample from the book:

public fi         


        
8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 01:13

    There is an assertion: "I'm asserting that this constructor will never be called". So, indeed, AssertionError is correct here.

提交回复
热议问题