------解决方案-------------------- foo这个类是public,一个文件中只可以有一个public的类,这个类的名字恰恰也是文件的名字。所以bar是一个内部类,内部类和外部类之间可以访问的。所以不会出现错误。
------解决方案-------------------- The class "Bar" is not inside the class "Foo", so it is not the inner class, but the parallel class to Foo. Thus, it is also why we can not declare the "Bar" class as "public" because the fist layer public class should be declared in his own file. And if you declare two parallel classes as "public", the JVM would not know which source file it belongs to, it is to say that the Java compiler would throw errors just because of the ambiguity.
------解决方案-------------------- public类只是说与其同名的文件内只能有一个,并不是说一定要有public类不可。
------解决方案--------------------