Multiple classes in a single Java file, each with a main method - unexpected behavior?

橙三吉。 提交于 2019-12-01 08:30:53

Presumably you're running on Windows, right?

That means you can't have two classes which differ only in case - because they'll both end up wanting to be in the same file, as Test.class and test.class are effectively the same filename in case-insensitive file systems.

It's not really a bug in Java - just an unfortunate but natural corollary of using a case-insensitive file system in conjunction with a language which attaches meaning to filenames.

@dark_secrets, You have to begin a class name with a capital letter in JAVA or else you will get an error while compiling.

use public (then class name).... that will definetely work....

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!