title: java : Inside Enhanced for loop cannot Object to String
body: <p>I have taken this example from net .
  But when i tried it is not compiling saying cannot convert Object to String </p>
  
  <pre><code>import java.util.ArrayList;
  
  public class Test {
  
      public static void main(String[] args) {
          ArrayList names = new ArrayList();
  
          names.add("Amy");
          names.add("Bob");
          names.add("Chris");
          names.add("Deb");
          names.add("Elaine");
          names.add("Frank");
          names.add("Gail");
          names.add("Hal");
  
          for (String nm : names)
              System.out.println((String)nm);
  
      }
  }
  </code></pre>
  
  <p>If it is a normal for loop i could have done list.get(element index).toString() .
  but how to do in enhanced for loop ??</p>