工具类用依赖注入来引用资源,而非使用static方法

 假设工具类为拼写检查器,它工做须要依赖字典,下面是工具类的一种经常使用写法:java public class SpellChecker { private static final Dictionary DICTIONARY = new Dictionary(); private SpellChecker() { throw new UnsupportedO
相关文章
相关标签/搜索