Java 的一个语言特性而已
> If an integer operator other than a shift operator has at least one operand of type long, then the operation is carried out using 64-bit precision, and the result of the numerical operator is of type long. If the other operand is not long, it is first widened (§5.1.5) to type long by numeric promotion (§5.6).
> Otherwise, the operation is carried out using 32-bit precision, and the result of the numerical operator is of type int. If either operand is not an int, it is first widened to type int by numeric promotion.
所以显示声明 是 long/(float|double),换句话说等价于 double period = (end - start)/(double) 1000000;
参见
https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.2这种问题,Google 搜一下因为英文关键词, "java division of integers" 前面几条都是有效答案。。