Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on "Final" modifier.

 
Sanjeev BhimaRao
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it possible in any scenario to manipulate or change the value of a variable marked "final" ? I believe it is not possible. Please let me know if someone knows about a possible scenario where this might be possible.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it's not possible.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sanjeev BA:
Hi,
Is it possible in any scenario to manipulate or change the value of a variable marked "final" ? I believe it is not possible. Please let me know if someone knows about a possible scenario where this might be possible.


Ofcourse you cann't change the reference of final variables. But you can change the value of a final Object. like this.



Hope it helps you.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And we're back to a discussion on reference/value

So you cannot change the value of a reference, nor the value of a primitive, marked as final. Of course, you can access the content of a reference.
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!