这怎么会在java中发生? [英] How come this is happening in java?

查看:20
本文介绍了这怎么会在java中发生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Windows 和 Java SE 7.

I am using Windows and Java SE 7.

我创建的类是TestPerson,保存为TestPerson.java.

The class I created was TestPerson, saved it as TestPerson.java.

但是当我尝试通过说 javac testperson.java 来编译它时,编译是成功的,并且 TestPerson.class 是使用确切的大小写字母创建的.

But when I try to compile it by saying javac testperson.java the compilation is succesfull and TestPerson.class is created with the exact case letters.

但是,Java 区分大小写,对吗?

But, Java is case sensitive, right?

怎么会这样?如果我们给出错误的情况,它应该显示一个错误.有什么具体原因吗?但是,在运行时它会显示错误.

How come this is happening? If we give the wrong case, it should show an error. Is there any specific reason? However, at run time it shows an error.

推荐答案

Java 区分大小写,但您的 Windows 文件系统可能不区分.

Java is case-sensitive, but your Windows file system may not be.

除非你有两个同名的类(不区分大小写),否则应该没有问题.Java 在技术上允许这样的事情(Hello 类和 HELLO 类),但这只是主动自找麻烦.对于非 ASCII 类名或非常长的类名(这同样适用于 Java,但可能不适用于必须存储类文件的文件系统).

Unless you have two classes with the same name (case-insensitive), it should not be a problem. Java technically allows such a thing (class Hello and class HELLO), but that would be just actively asking for trouble. Same goes for non-ASCII class names or very long class names (which again, are fine for Java, but maybe not for the filesystem that has to store the class files).

这篇关于这怎么会在java中发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆