title: Why is this legal in Java? Queue<String> waitingQueue = new LinkedList<>();
body: <p>In one of the tutorials on queues I saw following:</p>
  
  <pre><code>Queue&lt;String&gt; waitingQueue = new LinkedList&lt;&gt;();
  </code></pre>
  
  <p>Why is this statement valid in Java? </p>
  
  <p>I have seen <a href="https://stackoverflow.com/questions/383947/what-does-it-mean-to-program-to-an-interface">What does it mean to &quot;program to an interface&quot;?</a> but that does not explain the basic question of why above statement is valid. If Queue is an interface, how can I typecast an object to it? I can only implement Queue interface in a class to provide behavior I need. </p>
  
  <p>What am I missing?</p>