Java 7中0_0的含义 [英] Meaning of 0_0 in Java 7
问题描述
我已经阅读了Java7中的内容,现在我们可以写出这个有趣的声明:
I have read that in Java7, we can now write this funny statement :
public static boolean isZero(int O_O){
return O_O == 0_0;
}
问题是:在这种情况下 0_0
到底是什么意思?
The question is : What exactly does 0_0
mean in this context ?
推荐答案
出于可读性考虑,Java 7中允许在数字文字中使用下划线字符.从 javadocs :
Underscore characters in numerical literals are allowed in Java 7 just for the readibility purpose. From the javadocs:
在Java SE 7和更高版本中,可以使用任意数量的下划线字符(_)出现在数字文字中数字之间的任何地方.此功能例如,使您能够以数字分隔数字组文字,可以提高代码的可读性
In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example, to separate groups of digits in numeric literals, which can improve the readability of your code
这篇关于Java 7中0_0的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!