Java 1_1000_1000的意思

2017-04-25  本文已影响108人  SweetMain

今天偶然在 《Java8实战》这本书中发现了这样一段代码

public class CollectorHarness {
  public static void main(String[] args) {
    long fastest = Long.MAX_VALUE;
    for (int i = 0; i < 10; i++) {
      long start = System.nanoTime();
      partitionPrimes(1_000_000);
      long duration = (System.nanoTime() - start) / 1_000_000;
      if (duration < fastest) 
        fastest = duration;
      }
    System.out.println("Fastest execution done in " + fastest + " msecs");
  }
} 
1_1000_1000 这是什么?!

去查了一下还是不清楚,自己写了个测试类试试

@Test
public void test01() {
   System.out.println(222222222 / 1_1000_1000) ; // 2
   System.out.println(222222222 / 2); // 111111111
}

得出的结果是 1_1000_1000 表示 111111111(九个1)。

上一篇 下一篇

猜你喜欢

热点阅读