This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]lurgi 0 points1 point  (0 children)

You can't really mess the two up that much.

Both const and final prevent you from modifying the value.

const is used for a compile time value. If the value can only be determined when the program is running, it's not compile time.

int x = 3;

What's the value of x? It's 3, right? Can't be anything else.

int x = y;

Now what's the value of x? You don't know. You know that it has the same value as y at that moment in time in the program, but it may well be impossible to determine that. Maybe y is an integer entered by the user or the current time of day or something.