June 2018
Intermediate to advanced
310 pages
6h 32m
English
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?
Read now
Unlock full access