title: How to call a method in another class in Java?
body: <p>Currently I have two classes. a classroom class and a School class. I would like to write a method in the School class to call public void setTeacherName(String newTeacherName) from the classroom class.</p>
  
  <p><strong>classroom.java</strong></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;
      }
  }
  </code></pre>
  
  <p><strong>School.java</strong></p>
  
  <pre><code>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;
      }
  
      // how to write a method to add a teacher to the classroom by using the
      // classroom parameter
      // and the teachers name
  }  
  </code></pre>