title: Is there a parameter I can use in Java that works with all for-each loops?
body: <p>Suppose I've got a method that accepts an array and processes each element in it using Java's built in <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html" rel="noreferrer">for-each loop</a>, like this:</p>
  
  <pre><code>public static void myFun(SomeClass[] arr) {
      for (SomeClass sc : arr) {
          // Stuff is processed here
      }
  }
  </code></pre>
  
  <p>This works just fine, but now I want to be able to pass the same method a <code>List&lt;SomeClass&gt;</code> instead.  Am I destined to use <a href="http://java.sun.com/javase/6/docs/api/java/util/Collection.html#toArray(T[])" rel="noreferrer">Collection.toArray(T [])</a>, or is there a parameter I can use for <code>myFun()</code> that accepts any type that can be used in a for-each construct?</p>
  
  <p>To clarify: I want a method signature that will accept any iterable object, be it a primitive array or a Collection.  I can very easily write two methods, with one wrapping the other, but I'm just curious if there's a better way.</p>