gpt4 book ai didi

java - 工厂方法和实用类之间有什么区别?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:28:51 29 4
gpt4 key购买 nike

工厂方法和实用类有什么区别?什么时候用工厂方法,什么时候用工具类?

最佳答案

来自维基百科

In object-oriented programming, a factory is an object for creating other objects – formally a factory is simply an object that returns an object from some method call, which is assumed to be "new". Factory method Pattern

In computer programming, a utility class is a class that defines a set of methods that perform common, often re-used functions. Most utility classes define these common methods under static (see Static variable) scope. Utility Pattern

我想你可以猜到答案:)

关于java - 工厂方法和实用类之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28012495/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com