JLS - Java语言规范 - https://docs.oracle.com/javase/specs/jls/se9/html/index.html
JSR - Java规范请求 - https://jcp.org/aboutJava/communityprocess/final/jsr376/index.html(模块系统)正式文档,描述了用于添加到Java平台的建议规范和技术.
JEP - JDK增强提案- http://openjdk.java.net/jeps/0,http://openjdk.java.net/jeps/261(模块系统)
这三者有什么区别?
请考虑以下代码段:
// automatic casting works for int to byte conversion as integer literal 127
// is in the range for byte
byte b1 = 127; //OK
// automatic casting doesn't work for long to int conversion
// even if long literal is in the range of int.
int i5 = 100L; // NOT OK - compilation error
Run Code Online (Sandbox Code Playgroud)
这种行为有什么解释吗?
为什么在int到byte的情况下不需要显式转换,但需要long to int?
该如何转换的Java诠释成字节?问题不同.当int值超出范围时,它是关于int到byte的隐式转换的问题.