[1440] in java-interest

home help back first fref pref prev next nref lref last post

Local variables can't be final?

daemon@ATHENA.MIT.EDU (Ed Anuff)
Sat Sep 2 02:12:20 1995

Date: Fri, 1 Sep 1995 19:23:07 -0800
To: java-interest@java.sun.com, java@java.sun.com
From: edanuff@protagonist.com (Ed Anuff)

Are local variables allowed to be declared as final?  The compiler doesn't
complain about the following code:


class FinalTestApp {
        public static void main (String args[]) {
                final int x = 5;
                x = 10;
                System.out.println(x);
        }
}

I expected that x would be a constant and its value would not be able to be
changed, but this doesn't seem to be the case.

Ed


Ed Anuff
edanuff@protagonist.com
http://www.protagonist.com/


-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post