title: Non-public top level class in Java
body: <p>What's the reason of making top-level class non-public in Java?</p>
  
  <p>Let's say we have <code>Foo.java</code>, there could be</p>
  
  <pre><code>class Foo {
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>public class Foo {
  }
  </code></pre>
  
  <p>I understand that there will be some class - visibility issues with the former example (probably it won't be visible from other packages). But anyway, are there any reasons why someone may want to do as in the first code sample?</p>
  
  <p>UPD: What cons I see in the former solution: nobody cares that it's <code>non-public</code>. That class can be simply extended by some other <code>public</code> class in the same package later, then, non-public part of the class may bring you visibility/access issues.</p>