How to call a method in another class using the arraylist index in java?
<p>Currently I have two classes. A Classroom class and a School class.  </p>

<p><code>public void addTeacherToClassRoom(Classroom myClassRoom, String TeacherName)</code></p>

<p>I would like my method addTeacherToClassRoom to use the Classroom Arraylist index number to setTeacherName</p>

<p>e.g. 
int 0 = maths
int 1 = science</p>

<p>I would like to setTeacherName "Daniel" in int 1 science.</p>

<p>many, thanks</p>

<pre><code>    public class Classroom
{
private String classRoomName;
private String teacherName;

public void setClassRoomName(String newClassRoomName)
{
    classRoomName = newClassRoomName;

}

public String returnClassRoomName()
{
    return classRoomName;
}

public void setTeacherName(String newTeacherName)
{
    teacherName = newTeacherName;

}

public String returnTeacherName()
{
    return teacherName;
}
}





import java.util.ArrayList;

public class School
{
private ArrayList&lt;Classroom&gt; classrooms;
private String classRoomName;
private String teacherName;

public School()
{
    classrooms =  new ArrayList&lt;Classroom&gt;();
}

public void addClassRoom(Classroom newClassRoom, String theClassRoomName)
{
    classrooms.add(newClassRoom);
    classRoomName = theClassRoomName;
}

public void addTeacherToClassRoom(Classroom myClassRoom, String TeacherName)
{
    myClassRoom.setTeacherName(TeacherName);
}

}
</code></pre>
