title: How to run a method in a different class file in java
body: <p>So I have two files, gradebook which stores my main and some other methods and then FSCstudent which has my student class and some other things. I want to get an integer value from a getter. </p>
  
  <pre><code>public static void searchByID(int idSearch) {
      numStudents = FSCstudent.getNumStudents();
  }
  </code></pre>
  
  <p>So this is my attempt at trying to get the int value from this:</p>
  
  <pre><code>public int getNumStudents() {
      return numStudents;
  }
  </code></pre>
  
  <p>However, I just keep getting the error nonstatic method getNumStudents() cannot be referenced from a static context</p>