![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
design pattern
文章平均质量分 92
wangbingfeng0
I'm back
展开
-
type information - Using Class Literals
previous articleIf we reimplement PetCreator using lcass literals, the result is cleaner in many ways:// typeinfo/pets/LiteralPetCreator.java// (c)2017 MindView LLC: see Copyright.txt// We make no guarantees that this code is fit for any purpose.//原创 2020-12-30 23:56:12 · 211 阅读 · 0 评论 -
strings - Formatting Output
One of the long-awaited features that finally appeared in Java 5 is output formatting in the style of C’s printf() statement. Not only does this allowfor simplified output code, but it also gives Jav...原创 2019-05-03 16:02:39 · 174 阅读 · 0 评论 -
files - Directories
The Files utility class contains most of the operations we'll need for directory and file manipulation. For some reason, however, they did not include a tool to delete directory trees, so here we crea...原创 2019-04-22 22:59:09 · 223 阅读 · 0 评论 -
streams - generate()
Another approach to creating a separate factory class:// streams/Bubble.java// (c)2017 MindView LLC: see Copyright.txt// We make no guarantees that this code is fit for any purpose.// Visit http...原创 2019-01-26 16:47:37 · 154 阅读 · 0 评论 -
collections - The Adapter Method examples
When we have one inteface and we need another one, writing an adapter solves the problem.We want to add the ability to produce a reverse iterator to the default forward iterator, so We can’t overrid...原创 2019-01-15 20:52:34 · 81 阅读 · 0 评论 -
interface and factories
An interface is a gateway to multiple implementations, and a typical way to produce objects that fit the interface is the Factory Method design pattern.For example:// interfaces/Factories.java//...原创 2019-01-02 20:03:38 · 73 阅读 · 0 评论 -
use Scanner class example
A common use for interfaces is the aforementioned Strategy design pattern. You write a method that performs certain operations, and that method takes an interface you also specify. You’re basically sa...原创 2019-01-01 15:01:31 · 110 阅读 · 0 评论 -
collections - Iterator design pattern examples
An Iterator (since 1.2)can remove the last element produced by next(), which means you must call next() before you call remove().Iterator interface add new method default void forEachRemaining(C...原创 2019-01-10 21:33:43 · 198 阅读 · 0 评论 -
Complete Decoupling
Whenever a method works with a class instead of an interface, we are limited to using that class or its subclass. If we would like to apply the method to a class that isn't in that hierarchy, we're ou...原创 2018-12-31 17:37:09 · 254 阅读 · 0 评论 -
Inner class - Iterator design pattern example
When you create an inner class, an object of that inner class contains an implicit link to the enclosing object that made it. Through this link, it can access the members of that enclosing object, wit...原创 2019-01-03 22:13:42 · 116 阅读 · 0 评论