英文:
Filename changed after compiliation for java
问题
以下是翻译好的内容:
所以我有一个名为'anagram.java'的.java文件。
使用javac编译后,得到的.class文件命名为'Anagram.class'(A大写)
这可能看起来不重要,但到目前为止,我已经成功地在代码和编译后的文件中获得了相同的名称。有人知道这是为什么吗?
您可以在这里看到命令行的图片
英文:
So i had this .java file named as 'anagram.java'.
After compiling with javac the resultant .class file i get is named 'Anagram.class' (with a capital A)
This may seem inconsequential but so far, I've managed to get the same name in both the code and compiled file. Would anyone know why this happened?
You can see a picture of the commandline here
答案1
得分: 2
注意,对于Windows来说,javac对大小写不敏感,但对于Linux来说却是大小写敏感的。例如,在anagram.java文件中,你的类名是大写的,也就是说,它是class Anagram(应该是这样的),所以javac正在使用这个大写版本来生成你的类文件。通常情况下,将Java文件名也保持大写,因为这是惯例,而且根据操作系统的不同,javac在大小写不一致时可能无法正常工作。
英文:
Note that javac is case-insensitive for Windows, but not for Linux, for example. Your class name in the anagram.java file is capitalized, i.e. it is class Anagram (as it should be), so javac is using this capitalized version to make your class file. In general, keep java filenames capitalized as well since it is convention, and depending on the operating system, javac may not work with discrepancies in capitalization.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论