title: I want to count the number of Collections in a Collection, in a Collection with Streams
body: <p>Let's say I have a <code>SchoolDistrict</code>, that has many <code>Schools</code>, that has many <code>Students</code> that have many <code>Classes</code>.</p>
  
  <p>I want to count the number of classes given a SchoolDistrict.</p>
  
  <p>The Java 7 way would be like so:</p>
  
  <pre><code>Integer classCount = 0;
  for (School school : schoolDistrict)
  {
      for (Student student : school.getStudents())
      {
          classCount += student.getClasses().size();
      }
  }
  </code></pre>
  
  <p>I know that Java 8 brings streams that are supposed to make this kind of thing a bit easier on the eyes.</p>
  
  <p>But I'm having trouble figuring out how to do it.</p>
  
  <p>Any takers?</p>
  
  <p>EDIT: someone marked this as a duplicate of <a href="https://stackoverflow.com/questions/33317862/java-stream-api-count-items-of-a-nested-list">this post</a>, I don't believe it is as that example only went 2 levels deep (Countries to Regions). My question relates to a problem that goes four levels deep (SchoolDistricts to Schools to Students to Classes)</p>