title: Java: Why can a file not have more than one public class
body: <pre><code>public class A
  {
  }  
  
  public class B 
  {
      public static void main(String[] args) 
      {
      }
  }
  </code></pre>
  
  <p>Why cant we declare both class as public?<br>
  Why only <code>Main</code> class  can be public?
  i know that by making class public ,it will allow you access in package ok ,but what if i make  </p>
  
  <pre><code>     public    class a
       { 
  
       }
      class B
       {
      public static void main(String[] args) 
      {
  
       }
    }
  </code></pre>
  
  <p>why this code give error
   do we really need to notify that  main class is public bcoz every class is public</p>