title: Why don't I have to import a class I just made to use it in my main class? (Java)
body: <p>I am currently learning Java using the Deitel's book Java How to Program 8th edition (early objects version).</p>
  
  <p>I am on the chapter on creating classes and methods.</p>
  
  <p>However, I got really confused by the example provided there because it consists of two separate .java files and when one of them uses a method from the other one, it did not import the class. It just created an object of that class from the other .java file without importing it first. </p>
  
  <p>How does that work? Why don't I need to import it?</p>
  
  <p>Here is the code from the book (I removed most comments, to save typing space/time...):
  .java class:</p>
  
  <pre><code>//GradeBook.java
  
  public class GradeBook
  {
      public void displayMessage()
      {
          System.out.printf( "Welcome to the grade book!" );
      }
  }
  </code></pre>
  
  <p>The main .java file:</p>
  
  <pre><code>//GradeBookTest.java
  
  public class GradeBookTest
  {
      public static void main( String[] args)
      {
          GradeBook myGradeBook = new GradeBook();
          myGradeBook.displayMessage(); 
      }
  }
  </code></pre>
  
  <p>I thought I had to write </p>
  
  <pre><code>import GradeBook.java;
  </code></pre>
  
  <p>or something like that.
  How does the compiler know where GradeBook class and its methods are found and how does it know if it exists at all if we dont import that class?</p>
  
  <p>I did lots of Googling but found no answer.
  I am new to programming so please tolerate my newbie question.</p>
  
  <p>Thank you in advance.</p>