title: Why can I call the stream() method on objects of a class that don't have the stream()-method?
body: <p>I'm a novice Java programmer at university. I discovered something today that broke one of my conceptions about how Java syntax works.</p>
  
  <pre><code>public class testClass {
  
  ArrayList &lt;String&gt; persons = new ArrayList &lt;String&gt; ();
  
  public void run(){
      Stream &lt;String&gt; personstream = persons.stream();
  }}
  </code></pre>
  
  <p>The method <code>stream()</code> is not found in the <code>ArrayList</code> class, yet it might appear as if it's there. When I move my mouse over the <code>stream()</code>-method in Eclipse, it says it's part of Collections, but I don't find the <code>stream()</code> method anywhere in its online documentation. </p>
  
  <p>Why does it work to call the <code>stream()</code> method if it's not part of the class I'm calling it from?</p>