[英]Why does Java not complain about the reserve word Float?
I entered this in Eclipse and expected it to be the wrong syntax but it is allowed. 我在Eclipse中输入了这个,并期望它是错误的语法,但它是允许的。 Can someone please explain what is happening here?
有人可以解释一下这里发生了什么吗? Should the
Float
and Integer
keyword not be reserved? 是否应该保留
Float
和Integer
关键字? What type of assignment is this? 这是什么类型的任务?
Number Float = 99.455f;
Number Integer = 2;
No, Float
is not reserved word. 不,
Float
不是保留字。 float
is reserved word. float
是保留字。 Here is list of reserved words in java 这是java 中保留字的列表
You are creating a variable with the name Float
. 您正在创建名为
Float
的变量。 That's all. 就这样。 It's not a reserved word.
这不是一个保留的词。 The compiler is not trying to interpret it as a class name due to the syntax of your statement.
由于语句的语法,编译器不会尝试将其解释为类名。 It's not invalid, even if it is bad form.
这不是无效的,即使它是不好的形式。
因为这不是保留的,所以它是自动装箱的。
Float(它是一个包装类)不是Java保留关键字,而是float(它是一个原始的)。
Java区分大小写, float
是保留关键字但Float
不是。
Float
is not a reserved word. Float
不是一个保守的词。 It is just a name of java.lang.Float class, and system library class names (even from java.lang
) are not reserved. 它只是java.lang.Float类的名称,系统库类名(甚至来自
java.lang
)不是保留的。 float
is a reserved word. float
是一个保留字。 You can also have 你也可以
int String = 1;
but I would not advise. 但我不建议。
How about these , these also compile. 这些怎么样,这些也可以编译。 No deference from Float or Integer which are no reserved key words but Class names
Float或Integer没有任何保留关键词而是类名
String String = "";
Math Math = null;
Object Object = null;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.