• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

regarding final....

 
Ranch Hand
Posts: 126
VI Editor Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recall your SCJP memories.

rancher is final, but its content can still be manipulated.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic