Java JDK 中使用的设计模式示例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3649754/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 03:09:52  来源:igfitidea点击:

Examples of Design Patterns used in JDK

design-patternsjava

提问by Pram

Possible Duplicate:
Examples of GoF Design Patterns

可能的重复:
GoF 设计模式示例

At an interview a while back I was asked for some examples of Design Patterns within the JDK.

在不久前的一次采访中,我被要求提供一些 JDK 中设计模式的示例。

Off the top of my head I was able to identify

在我的头顶上,我能够识别

Flyweight - as used in the String pool Singleton - in java.lang.Runtime Iterator - as used on Collections classes

Flyweight - 用于字符串池 Singleton - 在 java.lang.Runtime Iterator 中 - 用于 Collections 类

Not that many.

没有那么多。

What are the other good examples of Design Patterns as used in the JDK?

JDK 中使用的其他设计模式的好例子是什么?

采纳答案by pakore

Observerinterfaces, you have them out-of-the-box.

观察者接口,您拥有开箱即用的接口。

For a complete answer, read this: Examples of GoF Design Patterns in Java's core libraries

如需完整答案,请阅读:Java 核心库中的 GoF 设计模式示例

回答by Nate W.

You can try a straightforward approach: goto the JDK Javadocand search for (Ctrl + F) the names of some design patterns. For example,

您可以尝试一种简单的方法:转到JDK Javadoc并搜索 ( Ctrl + F) 一些设计模式的名称。例如,

回答by Colin Hebert

Ouch, that's a tough question. Patterns are used almost everywhere in java. You can find some patterns used in Java EE on the Java BluePrints page.

哦,这是一个棘手的问题。模式在java中几乎无处不在。您可以在 Java BluePrints 页面上找到一些 Java EE 中使用的模式。



Resources :

资源 :