Creating an object based on the state of another object in Java
<p>Lets say you have a class called Explosion where it does not make sense to create an instance of it, without some information from another class instance. The constructor is not made public.</p>

<p>Is it better to do it this way:</p>

<pre><code>// both classes are in the same package  
Explosion e;  
Collision c = new Collision()    
// do some stuff with collision  
e = c.createExplosion()
</code></pre>

<p>Or is it better for Explosion to have a static method for creating an instance and you pass in a Collision object as an argument:</p>

<pre><code>Explosion e  
Collision c = new Collision()    
// do some stuff with collision  
e = Explosion.createExplosion(c)
</code></pre>

<p>When you are the author of both classes.</p>
