Results 1 to 7 of 7
  1. #1
    Aboogesnickle is offline Member
    Join Date
    Jun 2014
    Posts
    37
    Rep Power
    0

    Default How boolean stacks work?

    If you put a true boolean on a stack and then change the value to false, when you peek() or pop() does it return the true value it was when put in the stack or the false it was changed to after it had gone on the stack?

  2. #2
    Aboogesnickle is offline Member
    Join Date
    Jun 2014
    Posts
    37
    Rep Power
    0

    Default Re: How boolean stacks work?

    Another way to put this is, Does it make a copy of the object in the stack or does it put a reference/address on the stack to the object?

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: How boolean stacks work?

    put a true boolean on a stack and then change the value to false
    I think Boolean class instances are immutable because I don't see any methods to change its value.
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    Aboogesnickle is offline Member
    Join Date
    Jun 2014
    Posts
    37
    Rep Power
    0

    Default Re: How boolean stacks work?

    booleanA = true;

    push(booleanA);

    booleanA = false;

    booleanB = pop();

    Would booleanB be true or false?

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: How boolean stacks work?

    Would booleanB be true or false?
    Write the code and execute it to see.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    Aboogesnickle is offline Member
    Join Date
    Jun 2014
    Posts
    37
    Rep Power
    0

    Default Re: How boolean stacks work?

    Returns true

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: How boolean stacks work?

    Ok, now you know.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 6
    Last Post: 01-16-2014, 02:48 PM
  2. Replies: 5
    Last Post: 07-12-2013, 02:22 AM
  3. Replies: 3
    Last Post: 05-11-2013, 07:27 AM
  4. Replies: 3
    Last Post: 09-13-2011, 01:01 AM
  5. boolean error help when no boolean is given
    By drewtrcy in forum New To Java
    Replies: 18
    Last Post: 05-05-2011, 10:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •