-1

I have started learning java and there is this one line which I am not getting clearly that -

Variables are interpreted at runtime whereas values/constants at compile time ??

Can anyone explain this with suitable code..

4

1 回答 1

0

编译时常量:原始类型或字符串,声明为 final,在其声明中初始化,并带有常量表达式。例子:

public final int maximumLoginAttempts = 5;

运行时常数:程序运行时值不能改变。但是,每次我们运行应用程序时,它都可以有不同的值: 示例:

public static void main(String[] args) {
    Console console = System.console();
    final String input = console.readLine();
    console.writer().println(input);
}
于 2021-07-30T09:26:22.710 回答