Object Allocation through new operator or some interface
<p>I was going through a Java code and I saw that objects have been allocated using some interface and this interface contains some methods to allocate objects using <code>new</code> operator. I am unable to think that why they have used an interface instead of just directly allocating objects using <code>new</code> operator. e.g:</p>

<pre><code>Animal animal = new Animal();
</code></pre>

<p><strong>OR</strong></p>

<pre><code>Animal animal = interface.allocateAnimal()
</code></pre>

<p>here <code>interface</code> is an interface having a method <code>allocateAnimal</code> which does nothing but 
<code>new Animal()</code>.</p>

<p>So ultimately we are doing same thing but in different way so what are gaining here?</p>

<p>EDIT 1: Actually interface is implemented somewhere else. So interface does not contain any implementation code, it just contains methods.</p>
