如果你定義的類僅僅是包含了一些靜態的方法和靜態的欄位,這些類一般是一些工具類,這些一般是設計為不能被例項化的。
1. Attempting to enforce noninstantiability by making a class abstract does not work.
2. a class can be made noninstantiable by including a private constructor
// Noninstantiable utility class public class UtilityClass { // Suppress default constructor for noninstantiability private UtilityClass() { throw new AssertionError(); } ... // Remainder omitted }