简体   繁体   English

为什么Java不抱怨保留字Float?

[英]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? 是否应该保留FloatInteger关键字? 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.

相关问题 为什么checkstyle抱怨这个? - Why does checkstyle complain about this? 为什么jruby抱怨有效的java_opts - Why does jruby complain about valid java_opts 为什么javac抱怨没有初始化变量? - Why does javac complain about not initialized variable? 为什么Eclipse Java编译器会抱怨内部派生类型的未经检查的强制转换? - Why does the Eclipse Java compiler complain about an unchecked cast for inner derived types? 为什么Java编译器会抱怨本地变量未在此处初始化? - Why does the Java compiler complain about a local variable not having been initialized here? 为什么Java编译器会抱怨显式导入名称冲突而不是导入包。*? - Why does the Java compiler complain about explicit import name conflicts but not import package.*? Java:为什么编译器会在这里抱怨? - Java: Why does the compiler complain here? 为什么junit抱怨缺少xsl文件? - Why does junit complain about missing xsl files ? 为什么Eclipse为什么抱怨不安全的类型转换? - Why does Eclipse complain about unsafe type casting? 为什么Netbeans抱怨同步呼叫被条件包裹? - Why does Netbeans complain about a synchronized call being wrapped with a conditional?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM