• Post Reply Bookmark Topic Watch Topic
  • New Topic

can final variales be manipulated?  RSS feed

 
Yashashree Kale
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HFSJ(2nd edition) while discussing thread safty for instance variables they say, "even a final variable can still be manipulated unless it is immutable" (pg. 204) . I didn't get the meaning, please help!!
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What they probably mean is this: If a variable is final, then the value of the variable itself cannot be changed; but if the variable refers to an object, then you can still change the contents of that object (if the object is not immutable).

I'm going to move this to the Java in General (Beginner) forum, since it's not a question specifically about servlets.
 
Yashashree Kale
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesper Young:
What they probably mean is this: If a variable is final, then the value of the variable itself cannot be changed; but if the variable refers to an object, then you can still change the contents of that object (if the object is not immutable).

I'm going to move this to the Java in General (Beginner) forum, since it's not a question specifically about servlets.
THANKS Jesper

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!