JDK 7中的数字新写法

参见 http://download.java.net/jdk7/docs/technotes/guides/language/underscores-literals.html


在jdk7中,数字可以加入下划线:

long creditCardNumber = 1234_5678_9012_3456L;
long socialSecurityNumber = 999_99_9999L;
float pi =     3.14_15F;
long hexBytes = 0xFF_EC_DE_5E;
long hexWords = 0xCAFE_BABE;
long maxLong = 0x7fff_ffff_ffff_ffffL;
byte nybbles = 0b0010_0101;
long bytes = 0b11010010_01101001_10010100_10010010;

 

下划线不改变数字字面值,只增加可读性(真的吗?)

 

你可能感兴趣的:(JDK7)