-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..

1 Answers1

0

A Compile-time Constant: a primitive type or String, declared final, initialized within its declaration, and with a constant expression. Example:

public final int maximumLoginAttempts = 5;

A Runtime Constant: value cannot change while the program is running. However, each time when we run the application, it can have a different value: Example:

public static void main(String[] args) {
    Console console = System.console();
    final String input = console.readLine();
    console.writer().println(input);
}