摘要: 通常来说,我们认为hashCode不相同就为不同的对象。就这样由一段代码引发了一场讨论,代码如下: 有兴趣的话先猜一猜上面的打印结果。这段代码可以很好的说明String在创建对象的特殊性。运行上面的代码结果为: 猜对了吗?会不会有点奇怪,接下来我将逐一说明,并解释String创建对象的机理。首先我们 阅读全文
posted @ 2019-07-24 15:17 Mario0315 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 概念: 解释器模式:Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in t 阅读全文
posted @ 2019-07-04 18:19 Mario0315 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 概念: 状态模式:Allow an object to alter its benhavior when its internal state changes. The object will appear to change its class. 当一个对象内在状态改变是允许改变行为,这个对象看起 阅读全文
posted @ 2019-07-04 18:15 Mario0315 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 概念: 访问者模式:Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the 阅读全文
posted @ 2019-07-04 18:09 Mario0315 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 概念: 备忘录模式:Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later. 阅读全文
posted @ 2019-07-04 18:03 Mario0315 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 概念: 观察者模式:Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notifued and updated automatic 阅读全文
posted @ 2019-07-04 17:39 Mario0315 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 概念: 中介者模式:Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each 阅读全文
posted @ 2019-07-04 17:36 Mario0315 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 概念: 迭代器模式:Provide a way to access the elements of an aggregarte object sequentiaally with exposing its underlying representation. 提供一种访问容器对象内每个元素的一种方式 阅读全文
posted @ 2019-07-04 17:05 Mario0315 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 概念: 策略模式:Define a family of algorithms, encapsulate each one, and make them interchangeable. 定义一组算法,封装每个算法,并使他们之间可以互相转换。实现: 抽象的策略类 具体的策略实现类 总的调用类 测试及结 阅读全文
posted @ 2019-07-04 16:47 Mario0315 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 概念: 责任链模式:Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receivering 阅读全文
posted @ 2019-07-04 16:24 Mario0315 阅读(121) 评论(0) 推荐(0) 编辑