title: Instantiating interfaces in Java
body: <p>I have this interface:</p>
  <pre><code>public interface Animal {
      void Eat(String name);
  }
  </code></pre>
  <p>And this code here implements the interface:</p>
  <pre><code>public class Dog implements Animal {
      public void Eat(String food_name) {
          System.out.printf(food_name);
      }
      
      public static void main(String args[]) {
          Animal baby2 = new Dog(); // &lt;- this line
          baby2.Eat(&quot;Meat&quot;);
      }
  }
  </code></pre>
  <p>My question is, why does the code work? An interface cannot be instantiated. Yet in this case, interface was instantiated (marked with the comment).</p>
  <p>What is happening here?</p>