• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt from Head First Servlets & JSP

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I the Head First Servlets & JSP 1.4
page no 202

one statement is there :
And since you're a Java programmer you know that even a final variable can still be manipulated unless it's immutable.

Please clearify me this line with a proper example
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "And since you're a Java programmer... " part tells us that this is a core Java issue, not a servlet specific one.

I'm going to move this to our Java In General (Intermedite) forum where this gets discussed from time to time.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a nice introduction to Java variables.
It's both easy and fun to read.
http://www.javaranch.com/campfire/StoryCups.jsp

After you read it, remember that final means that the remote can never point to another TV. Nor can you exchange the remote in the cup for another one.

It doesn't mean that the TV can't be altered to play a different channel.

See if that helps.
[ May 23, 2008: Message edited by: Ben Souther ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try The below link
http://mindprod.com/jgloss/final.html . It talks about "Blank Final Variables". I think the reference in Head First is regarding this.


Hope it helps.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Amit Kumar Arora.

The "blank final variable" of the Mindprod website you quoted is an intermediate stage; a variable (better called a field) has been declared butnot yet initialised, so it must be initialised by every constructor.

A final field may point to a reference type, but cannot be altered. The state of the object which is that reference type might however be altered. that is probably what the Head First quote means. You can "change the channel" as Benm Souther has told you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic