title: Cannot Access Java Class Exception - Access Specifier Limitation
body: <pre><code># EvenDriver.java
  package com.EventDrivenScenario.SystemElements;
  
  import com.EventDrivenScenario.Exceptions.TableFullException;
  import java.util.Random;
  
  public class Table {
       static final int TABLE_SIZE = 6;
       static int tableCurrentSize;
       Table(){
       }
       public static void main(String args[]){
            Random eventTrigger = new Random();
            while(true){
                 try {
                     if(eventTrigger.nextLong()%2 == 0){
                          new HumanBeing();
                     }
                     if (tableCurrentSize == TABLE_SIZE) {
                         throw new TableFullException();
                     }
                 } catch(TableFullException e) {
                        System.out.println(e.getMessage());
                        break;
                 }
           }
       }
  }
  
  class HumanBeing{
      HumanBeing(){
           new Chairs();
      }
  }
  
  class Chairs{
       Chairs(){
           Table.tableCurrentSize++;
       }
  }
  # TableFullException
  package com.EventDrivenScenario.Exceptions;
  public class TableFullException extends Exception{
      TableFullException(){
  
      }
      public String getMessage() {
           return ("Table Full - No More Visitors");
      }
  }
  </code></pre>
  
  <p>In the above code when i try to compile #EventDriver.java, I am getting compile time error indicating that TableFullException is not public and cannot be accessed outside package in spite of declaring it as public.</p>
  
  <p>but if I change the package statement in both files to ##package com.EventDriver;## It works fine. I just want to understand why the above code throwing compile time error in spite of provide public access specifier for TableFullException.</p>