代码示例:
public class StringHolder{ public static final String ONE = "ONE"; public static final String TWO = "TWO"; public static final String THREE = "THREE"; public static void main (String[] args){ String someVariable = ONE + TWO + THREE; } }
我如何从静态常量来评估String值?例如,使用Intellij Idea,我可以在调试中运行程序,放入断点,在表达式上按“ctrl alt f8”,看到表达式值.那么可以用静态分析器来评估这个与编译代码和运行程序?
关键点是从静态常量不是从函数参数计算的值,所以分析器只是“去”到常量值,连接它们并在弹出窗口中显示我的值.
另一种情况,当我有一个块和“刚刚初始化”变量:
{ final String a = "a"; final String b = "b" final String c = "c" String result = a+b+c; }
附:你明白我了吗?