title: Programming to Interfaces is awesome and I agree 100% but would it always be possible?
body: <p>Here is an example:</p>
  
  <p>A concrete implementation may have some specific behavior like implementation of <code>ArrayList</code> has <code>ensureCapacity()</code> which is not applicable to <code>LinkedList</code>. </p>
  
  <pre><code>//programming to interface not implementation
  List list = new ArrayList();
  list.add("hi");
  list.add("hello");
  
  // now I need to use some method from ArrayList e.g. ensureCapacity() 
  list.ensureCapacity(); // can't as list is List with no ensureCapacity()
  </code></pre>
  
  <p><strong>Edited to include more details:</strong></p>
  
  <p>2nd example scenario:</p>
  
  <pre><code>List list=new LinkedList();
  Iterator li=list.listIterator();// Program to interface rule
  li.add("Hi");// NOT allowed as add() is part of ListIterator
  </code></pre>
  
  <p>Q1. If we are supposed to 'program to interface', what is the need of specific methods like "add()" in ListIterator and ArrayList?</p>
  
  <p>Q2. Does "Programming to an interface" mean "apply this concept as much as you can but you can't always"?</p>
  
  <p>Q3. Would it be better to use ListIterator instead of Iterator?</p>