• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can you set the value of a Boolean?

 
Rick Crawford
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question: is it possible to set the value of a Boolean after it has already been constructed?
For example, suppose I create my Boolean like this:
Boolean myBoolean = new Boolean(false);
..then later on in the code, I need to reset the value:
if (x == y) {
// Based on this condition, I need to set the booleanValue within the object to Boolean.TRUE
}
Thanks for any assistance,
Rick <><

------------------
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrapper classes like Boolean and the others are immutable, i.e. we cannot change the value they hold after having created them. The only thing you can do is create a new Boolean object and assign it to myBoolean.
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Rick Crawford
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much for the info.
This list is absolutely the greatest! I look forward to the day that I can actually help instead of always being the one that is helped!
Rick <><
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By being helped sometimes we do help Maybe others have the same question and now don't need to ask. Or we read a question and answer and file it away for later use.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic