1Jshell脚本工具
此特性主要用于轻量小工具操作
退出/exit
2常量优化
变量赋值过程中,若右侧的表达式全是常量,没有变量,那么在未进行运行时,变量值就已经完成计算。
public class Hello{ public static void main(String[] args){ //正确写法,左侧没有超过左侧的范围 short num1 = 10; short num2 = 5; // 错误写法,左边需要时int 类型 short num3 = num1 + num2; //右侧没有变量,只有常量 short result = 4 + 3; System.out.println(result); } }
原文:https://www.cnblogs.com/rango0550/p/10702425.html