Jacky Pepper wrote:In both ways there is a OtherClass instance-object available, isn't it? Is there a difference?
In effect: no. In flexibility: yes. The first style forces you to be able to construct the object from intrinsic data. With the second, you could pass runtime parameters to the constructor that allow you construct the object more dynamically. Note that this also applies if 'otherClass' is marked final.
Bats fly at night, 'cause they aren't we. And if we tried, we'd hit a tree -- Ogden Nash (or should've been).
Articles by Winston can be found here
Joined: Jul 20, 2012
Thanks John and Winston!
... to be more clear, the examples should look like that: