Why can final constants in Java be overridden?

You are hiding it, it’s a feature of “Scope”. Any time you are in a smaller scope, you can redefine all the variables you like and the outer scope variables will be “Shadowed”

By the way, you can scope it again if you like:

public class A implements I {
    public String KEY = "b";

    public String getKey() {
        String KEY = "c";
        return KEY;
    }
}

Now KEY will return “c”;

Edited because the original sucked upon re-reading.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)