Priya, I think it's because you're asking whether one new Boolean object is the same as another new Boolean object. The answer is no because they are two different objects (though they contain the same value). To get an answer of "True", you could ask either: if ((boolean x = true) == (boolean y = true)) or.. if ((new Boolean("true")).equals((new Boolean("true")))) Does that sound right? g.
Please the general subjects as "a doubt" or "help" are a bad choice because they don't give a clue about the real matter. People cannot decide if they are interested in the post beforehand. Also it is not very helpful for searches. Thanks.
If you want to compare the addresses in memory of two object references, use == If you want to compare the state of two objects, use equals() (except when using equals() of Object class, which behaves like ==. Any other class which does not override this also inherits the same behavior for equals()).