4 Comments

  1. Dan Zhuo

    Java Boolean Wrapper class is not design properly, which shouldn’t expose such constructor, if it was design after Enum, it would be just two enum values – TRUE, FALSE, and could just do == and !=, similar to boolean primitive did. It is up to developer to decide which String should be considering as “truthy” using Factor design.

    Reply
  2. Derek Berner

    When == or != is checked on the Boolean, the boolean primitive is compared.

    This is incorrect. Boolean objects are not unboxed for == and !=. The reason “3” is not printed is because test1() and test2() return boolean primitives, so they are unboxed before the function returns.

    Reply

    • Thanks Derek !! This has been updated in the quiz.

      Reply

Leave a Reply