- Hands-On Design Patterns with Kotlin
- Alexey Soshin
- 74字
- 2021-06-25 20:49:28
Static Factory Method
The Static Factory Method was popularized by Joshua Bloch in his book Effective Java. To understand it better, let's look at the examples from Java standard library itself, the valueOf() methods:
Long l1 = new Long("1");
Long l2 = Long.valueOf("1");
Both the constructor and the valueOf() method receive String as input and produce Long as output.
So, why is the Static Factory Method sometimes better than a constructor?
推薦閱讀
- 程序員修煉之道:程序設(shè)計(jì)入門30講
- CockroachDB權(quán)威指南
- LabVIEW Graphical Programming Cookbook
- Power Up Your PowToon Studio Project
- Java EE框架整合開發(fā)入門到實(shí)戰(zhàn):Spring+Spring MVC+MyBatis(微課版)
- SQL Server 2012數(shù)據(jù)庫技術(shù)及應(yīng)用(微課版·第5版)
- INSTANT Sencha Touch
- 精通軟件性能測試與LoadRunner實(shí)戰(zhàn)(第2版)
- MariaDB High Performance
- Mastering JBoss Enterprise Application Platform 7
- 匯編語言編程基礎(chǔ):基于LoongArch
- 區(qū)塊鏈國產(chǎn)化實(shí)踐指南:基于Fabric 2.0
- 青少年學(xué)Python(第2冊)
- 跟小樓老師學(xué)用Axure RP 9:玩轉(zhuǎn)產(chǎn)品原型設(shè)計(jì)
- Practical Responsive Typography