title: Java unable to ForEach an array list of a custom class (incompatible type)
body: <p>When I attempt to foreach through an array list of objects of a custom class I get the following error: error: </p>
  
  <p>"incompatible types: (object) cannot be converted to ArrayList."</p>
  
  <p>After reading through several other posts like <a href="https://stackoverflow.com/questions/43420331/what-causes-incompatible-types-java-lang-object-cannot-be-converted-in-a">this one</a> I thought I was just missing casting or making the object type explicit in my declaration. However after fixing it the problems persists. </p>
  
  <pre><code>ArrayList&lt;Room&gt; roomList = new ArrayList&lt;Room&gt;();
  
  for (final ArrayList room: roomList)
  </code></pre>
  
  <p>What am I missing? If it makes a difference I'm using <a href="https://ide.geeksforgeeks.org/" rel="nofollow noreferrer">this</a> online compiler as my IDE.</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  class SchedulingApplication
  {
      ArrayList&lt;Room&gt; roomList = new ArrayList&lt;Room&gt;();
      int roomCount = 0;
  static class Meeting
  {
      double startTime;
      double endTime;
  }
  static class Room
  {
      int roomNumber = 0;
      ArrayList&lt;Meeting&gt; meetingList = new ArrayList&lt;Meeting&gt;();
  }
  
  
  void addNewMeeting(double start, double end)
  {
      Meeting meeting = new Meeting();
      checkConflict(meeting);
      return;
  
  }
  
  void addNewRoom(int number)
  {
      Room room = new Room();
      room.roomNumber = number;
      roomCount++;
      roomList.add(room);
  }
  int checkConflict(Meeting newMeeting)
  {
      //boolean isScheduled = false;
      boolean isConflict = false;
      if (roomCount == 0)
      {
          roomCount++;
          return roomCount;
      }
      else
      {
              for (final ArrayList room: roomList)
              {
                  isConflict = false;
                  for (final ArrayList  oldMeeting: room.meetingList())
                  {
                      //see if the new meeting starts during all of the old meetings in this room
                      if (newMeeting.startTime &gt; oldMeeting.startTime &amp;&amp; newMeeting.startTime &lt; oldMeeting.endTime)
                      {
                          isConflict = true;
                          break;
                      }
                  }
                  if (!isConflict)
                  {
                      //isScheduled = true;
                      return room.roomNumber();
                  }
              }
  
      }
  
  }
  
      public static void main (String[] args) {
  
  
  
  
  }
  </code></pre>
  
  <p>}</p>