title: in Enumeration<Object> eo1 = p2.propertyNames(), why is it necessary to cast p2.propertyName() to Enumeration<Object>?
body: <p>I'm trying to learn the Java class Properties. I want to print out the list of properties's key. However, the IDE displayed the following error: </p>
  
  <pre><code>Enumeration&lt;Object&gt; eo1 = p2.propertyNames();
  //error, cast...propertyNames(...) to Enumeration
  </code></pre>
  
  <p>I made the following change: </p>
  
  <pre><code>Enumeration&lt;Object&gt; eo1 = (Enumeration&lt;Object&gt;) p2.propertyNames();
  </code></pre>
  
  <p>And everything works fine. However, I was just wondering why I need to cast <code>propertyNames()</code> to <code>Enumeration&lt;Object&gt;</code>. I know <code>p2.propertyNames()</code> return a object of Enumeration, but the syntax is very confusing for a beginner like me.</p>
  
  <pre><code>Properties p1 = new Properties();
  
  try (OutputStream os1 = new FileOutputStream("random.txt")){
      p1.setProperty("1", "one");
      p1.setProperty("2", "two");
      p1.setProperty("3", "three");
      p1.store(os1, "comment");
  } catch(IOException e){
      e.printStackTrace();
  }
  
  Properties p2 = new Properties();
  try (InputStream is1 = new FileInputStream("random.txt")){
      p2.load(is1);
      System.out.println(p2.getProperty("2"));
  } catch (IOException e){
      e.printStackTrace();
  }
  
  Enumeration&lt;Object&gt; eo1 = p2.propertyNames();
  while (eo1.hasMoreElements()){
      System.out.println(eo1.nextElement());
  }
  </code></pre>