• Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt from Head First Servlets & JSP  RSS feed

 
Deepak Yadav
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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 ]
 
amit kumar arora
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!