File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes regarding final.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "regarding final...." Watch "regarding final...." New topic
Author

regarding final....

Guru dhaasan
Ranch Hand

Joined: Sep 13, 2006
Posts: 126

In p:202 of Head first Servlets & JSP book, we have the following para.

"...and since you are a Java programmer, you know that even a final variable still be manipulated unless its immutable"

Can anyone explain how a final can be manipulated ?


Thanks, Shiv
SCJP, OCE - JSP & Servlets Developer
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Recall your SCJP memories.

rancher is final, but its content can still be manipulated.


[My Blog]
All roads lead to JavaRanch
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Consider the following:



You would expect 'final' to prevent the value of a variable to change, but it just prevents it from changing to a new instance. If the value of the instance can be altered (ie it is not immutable) then the value returned by the final instance can change, even if the instance does not.

Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding final....