I think , this should not be assigned 'null' . correct me if i am wrong
Joined: Feb 07, 2005
No it should not be assigned to null. Based on the message the compiler gives, this is a final variable associated with the class and like other final variables, it cannot be assigned a new value. But that isn't ambiguous.
If I remember correctly, an early version of the Eclipse compiler didn't flag assignment to "this" as an error. I don't remember whether that was a bug, or something that actually officially changed with later Java versions...
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
On which Java version? Did you see what the people above are saying about Eclipse? Are you using Eclipse? Eclipse has its own built-in Java compiler. According to the bug report above, there's a bug in Eclipse that allows you to assign a value to "this". It shouldn't be possible.
It's not interesting to find out why it still works - it's an illegal Java program and the behaviour is undefined. You noticed that the System.out.println() still works, but it just as well could not have worked. What the program does, is undefined. It could do anything. It could even make your hair turn purple. [ April 06, 2006: Message edited by: Jesper de Jong ]